Announcement

Collapse
No announcement yet.

mvmakeindex query

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    mvmakeindex query



    I'm working with MVM v 4.xx and want to generate indexes dynamically.
    I'm being lazy and rather than solving this myself, I'm throwing it out there for the rest of
    you to comment on.

    Something like this works fine,

    <mvmakeindex name="dbAlias" indexfile="{g.strDataRoot $ 'Xindex1.mvx'}"
    expression="{dbAlias.d.field}">

    or this

    <mvmakeindex name="{dbFields.d.alias}" indexfile="{g.strDataRoot $ 'Xindex1.mvx'}"
    expression="{dbAlias.d.field}">

    but what about this?

    <mvmakeindex name="{dbFields.d.alias}" indexfile="{g.strDataRoot $ 'Xindex1.mvx'}"
    expression="{miva_variable_value(dbFields.d.alias $ '.d.' $ dbFields.d.name)}">

    My gut feeling is that this would not work, because I would always need to have the
    database dbFields open when I want to read or write using the index. At this stage I'm
    not sure whether I would always want to do this.
    Also, what sort of overhead in processing time is using miva_variable_value() in an
    index likely to have if any?

    --
    Christopher Cookson
    Create IT, 4 Safe St, Blenheim
    ph +64 3 578 1721 mobile +64 274 969 735
    <A HREF ="http://www.createit.co.nz">http://www.createit.co.nz</A>



    #2
    mvmakeindex query



    On 5/10/05, Christopher Cookson <[email protected]> wrote:
    > I'm working with MVM v 4.xx and want to generate indexes dynamically.
    > I'm being lazy and rather than solving this myself, I'm throwing it out t=
    here for the rest of
    > you to comment on.
    >=20
    > Something like this works fine,
    >=20
    > <mvmakeindex name=3D"dbAlias" indexfile=3D"{g.strDataRoot $ 'Xindex1.mvx'=
    }"
    > expression=3D"{dbAlias.d.field}">
    >=20
    > or this
    >=20
    > <mvmakeindex name=3D"{dbFields.d.alias}" indexfile=3D"{g.strDataRoot $ 'X=
    index1.mvx'}"
    > expression=3D"{dbAlias.d.field}">
    >=20
    > but what about this?
    >=20
    > <mvmakeindex name=3D"{dbFields.d.alias}" indexfile=3D"{g.strDataRoot $ 'X=
    index1.mvx'}"
    > expression=3D"{miva_variable_value(dbFields.d.alia s $ '.d.' $ dbFields.d.=
    name)}">

    You can solve that with something like this...

    <MvASSIGN NAME=3D"l.expr" VALUE=3D"{miva_variable_value(dbFields.d.alias $
    '.d.' $ dbFields.d.name)}">

    <MvMAKEINDEX NAME=3D"{dbFields.d.alias}" INDEXFILE=3D"{g.strDataRoot $
    'Xindex1.mvx'}" EXPRESSION_TYPE=3D"variable" EXPR=3D"l.expr">

    > My gut feeling is that this would not work, because I would always need t=
    o have the
    > database dbFields open when I want to read or write using the index. At t=
    his stage I'm
    > not sure whether I would always want to do this.
    > Also, what sort of overhead in processing time is using miva_variable_val=
    ue() in an
    > index likely to have if any?

    Doubt that it's much, but you could always try running some benchmarks
    to be sure.

    > --
    > Christopher Cookson
    > Create IT, 4 Safe St, Blenheim
    > ph +64 3 578 1721 mobile +64 274 969 735
    > <A HREF ="http://www.createit.co.nz">http://www.createit.co.nz</A>
    >=20

    --=20
    Bill Guindon (aka aGorilla)


    Comment


      #3
      mvmakeindex query



      Indexes are efficient only if already available in the moment you need them.
      Creating them in runtime may not be always the best solution. It is
      certainly better having them ready in advance and open at each write
      operation to the database. Another possibility is reindexing them regularly.

      Yet another way, at smaller data sets, for getting them quickly sorted is
      using the trick Markus Gieppner posted when Miva introduced arrays and
      structures. You build an array (for numeric values) or a structure (for
      alfanum values) and store the values into the index resp. member name, and a
      pointer to the value (i.e. recno) to the array or structure member value.

      Markus posted sample code many times to the list, so searching the archive
      will help you in case of doubts.

      There are also other possible approaches - for example creating a more
      universal index; changing the data structure to better serve the purpose,
      combining both dB index and array sorting; designing fast searches with
      MvFILTER/MvFIND combination (with a trick described on my website),...

      It depends very much on several conditions which of the solutions will be
      the best. You best test the solution you can write quicker, to see if it
      meets the requirements. If not, then try another one.

      Ivo Truxa

      | http://miva.truxoft.com
      | Advanced Miva Merchant modules



      -----Original Message-----
      From: Christopher Cookson


      I'm working with MVM v 4.xx and want to generate indexes dynamically.
      I'm being lazy and rather than solving this myself, I'm throwing it out
      there for the rest of
      you to comment on.

      Something like this works fine,

      <mvmakeindex name="dbAlias" indexfile="{g.strDataRoot $ 'Xindex1.mvx'}"
      expression="{dbAlias.d.field}">

      or this

      <mvmakeindex name="{dbFields.d.alias}" indexfile="{g.strDataRoot $
      'Xindex1.mvx'}"
      expression="{dbAlias.d.field}">

      but what about this?

      <mvmakeindex name="{dbFields.d.alias}" indexfile="{g.strDataRoot $
      'Xindex1.mvx'}"
      expression="{miva_variable_value(dbFields.d.alias $ '.d.' $
      dbFields.d.name)}">

      My gut feeling is that this would not work, because I would always need to
      have the
      database dbFields open when I want to read or write using the index. At this
      stage I'm
      not sure whether I would always want to do this.
      Also, what sort of overhead in processing time is using
      miva_variable_value() in an
      index likely to have if any?



      Comment


        #4
        mvmakeindex query



        > Indexes are efficient only if already available in the moment you need them.
        > Creating them in runtime may not be always the best solution. It is
        > certainly better having them ready in advance and open at each write
        > operation to the database. Another possibility is reindexing them regularly.

        This is not a problem, as the index will only generally be created once in my scenario.
        I think Bill solved my problem for now with the expr_type="variable" option. This should
        work fine for any single field indexes
        I'm using this as part of a miva based table creation script, so that I can use a single
        function to create an index for any given table given the alias, and index field
        parameters.
        I've still got to try and resolve the situation where the index is a composite of two fields.

        --
        Christopher Cookson
        Create IT, 4 Safe St, Blenheim
        ph +64 3 578 1721 mobile +64 274 969 735
        <A HREF ="http://www.createit.co.nz">http://www.createit.co.nz</A>

        >
        > Yet another way, at smaller data sets, for getting them quickly sorted is
        > using the trick Markus Gieppner posted when Miva introduced arrays and
        > structures. You build an array (for numeric values) or a structure (for
        > alfanum values) and store the values into the index resp. member name, and a
        > pointer to the value (i.e. recno) to the array or structure member value.
        >
        > Markus posted sample code many times to the list, so searching the archive
        > will help you in case of doubts.
        >
        > There are also other possible approaches - for example creating a more
        > universal index; changing the data structure to better serve the purpose,
        > combining both dB index and array sorting; designing fast searches with
        > MvFILTER/MvFIND combination (with a trick described on my website),...
        >
        > It depends very much on several conditions which of the solutions will be
        > the best. You best test the solution you can write quicker, to see if it
        > meets the requirements. If not, then try another one.
        >
        > Ivo Truxa
        >
        > | http://miva.truxoft.com
        > | Advanced Miva Merchant modules
        >
        >
        >
        > -----Original Message-----
        > From: Christopher Cookson
        >
        >
        > I'm working with MVM v 4.xx and want to generate indexes dynamically.
        > I'm being lazy and rather than solving this myself, I'm throwing it out
        > there for the rest of
        > you to comment on.
        >
        > Something like this works fine,
        >
        > <mvmakeindex name="dbAlias" indexfile="{g.strDataRoot $ 'Xindex1.mvx'}"
        > expression="{dbAlias.d.field}">
        >
        > or this
        >
        > <mvmakeindex name="{dbFields.d.alias}" indexfile="{g.strDataRoot $
        > 'Xindex1.mvx'}"
        > expression="{dbAlias.d.field}">
        >
        > but what about this?
        >
        > <mvmakeindex name="{dbFields.d.alias}" indexfile="{g.strDataRoot $
        > 'Xindex1.mvx'}"
        > expression="{miva_variable_value(dbFields.d.alias $ '.d.' $
        > dbFields.d.name)}">
        >
        > My gut feeling is that this would not work, because I would always need to
        > have the
        > database dbFields open when I want to read or write using the index. At this
        > stage I'm
        > not sure whether I would always want to do this.
        > Also, what sort of overhead in processing time is using
        > miva_variable_value() in an
        > index likely to have if any?
        >





        Comment

        Working...
        X