home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / clipper / partidx3.arj / PARTINDX.DOC < prev    next >
Encoding:
Text File  |  1990-05-16  |  4.7 KB  |  100 lines

  1.                            Partial Indexing
  2.  
  3.                              Kevin Foley
  4.  
  5.                               05/16/90
  6.  
  7. Applications
  8. ============
  9.    Partial indexing is used when you need to manipulate a subset of a
  10.    VERY LARGE database.  The SET FILTER TO command could be used,
  11.    but it is very very slow when used with large databases.
  12.  
  13.    When I use the term large, I mean thousands of records.
  14.    For my personal needs, the files ranged from 4,000 to 217,000 records.
  15.  
  16.    To get around this problem a partial index can be built.  This
  17.       index contains only the pointers to the records you want, thus the
  18.    index is small.  The drawback is that it does take time to
  19.    create the index file, and you must have the memory available to build
  20.    the index.
  21.  
  22.    The time needed to create the index file is very small.  I would
  23.    guesstimate that the time needed to create a partial index of "n"
  24.    records is equal to less than twice the time needed to index a
  25.    database with "n"  records. So time is not an issue.
  26.  
  27.    The memory needed to generate an index may not be a problem to most
  28.    users.  But for those of us who use as much of the free pool as we
  29.    can, memory is an issue.   The only suggestion I have is to use
  30.    expanded memory to hold the index tables.  For those of us with AT
  31.    machines and the standard 384K + of extended memory, use a DOS
  32.    device driver to emulate expanded memory.  This is usually the VMEM.SYS
  33.    file.  When expanded memory is available,  Clipper will automatically
  34.    move the indexing tables from standard memory into expanded memory.
  35.    There is no need to use a SET CLIPPER environmental variable.
  36.  
  37.  
  38. mplementation
  39. ==============
  40.    Partial indexing is implemented through a Clipper procedure, using
  41.    the Clipper INDEX command, so the index file is Clipper compatable.
  42.  
  43.    You ask, "Isn't there a better way?", and I say to you, probably,
  44.    but so what.  I have called Nantucket support a bazillion times, to
  45.    ask how to create a mini index, and no one knows how.  There is a
  46.    file in the NANTUCKET forum called SUBNTX.ZIP, that contains a C
  47.    routine and some documentation, but this guy wants money before he
  48.    will let you get at the usable code.  Screw that idea.
  49.  
  50.    The implementation of the PARTINDX procedure was built on an idea
  51.    by Ira Emus.  I was lucky enough to find his example in the NANTUCKET
  52.    forum, under the file name INDEX.ZIP .  There was one flaw in his
  53.    example.  When using his "Partial3" function, the 1st record in the
  54.    array is always lost.  This is due to the fact that Clipper evaluates
  55.    the INDEX expression before actually skipping through the database
  56.    and creating the index tables.  This flaw has been repaired in PARTINDX.
  57.  
  58.    The documentation on partial indexing by Ira Emus, INDEX.TXT, is included
  59.    with this archive.  Please read it to learn more about partial indexing.
  60.  
  61.  
  62. Brass tacks
  63. ===========
  64.    The PARTINDX.prg is about 140 lines long, less the comments about 50
  65.    lines long.  The PARTINDX.obj is about 1677 bytes, less if you compile
  66.    without line numbers.
  67.  
  68.    You will notice that the code for displaying status has been commented
  69.    out.  You may choose to show status or not show status. The comments
  70.    are left there as an example of where to put the status displays.
  71.  
  72.    The example and usage of PARTINDX.prg is in the header of the file.
  73.    Read the NOTE: and Example: areas carefully.
  74.  
  75.  
  76. Common problems
  77. ===============
  78.    1. Problem: Seek fails, but dbedit shows record.
  79.       Reason.: The index expression (first parameter) was invalid.
  80.  
  81.    2. Problem: DBU or other programs display "UNKNOWN IDENTIFIER xFAKEOUT".
  82.       Reason.: 1. PARTINDX failed to rewrite the .ntx header information.
  83.                   User did not specifically specify the .ntx extention
  84.                   when naming the partial index (second parameter).
  85.                   Used "bob" instead of "bob.ntx".
  86.                2. Partial index is open in some other area, PARTINDX failed
  87.                   to exclusively open the partial index file for header
  88.                   rewrite.
  89.  
  90.    3. Problem: Index has 0, or not enough records.
  91.       Reason.: 1. The &KeyExpr and KeyValue expressions are never equal.
  92.                2. The optional UserFilter is never true.
  93.                3. The source database was not indexed on a key value.
  94.  
  95.    4. Problem: There is always 1 record in the index that does not fit
  96.                the KeyExpr and KeyValue criteria.
  97.       Reason.: PARTINDX will 99% of the time insert 1 bogus record, this
  98.                is actaully the last record in the database.  The only
  99.                way to get around this is to use the SET FILTER command.
  100.                Don't worry, this SET FILTER will be fast.