home *** CD-ROM | disk | FTP | other *** search
- Partial Indexing
-
- Kevin Foley
-
- 05/16/90
-
- Applications
- ============
- Partial indexing is used when you need to manipulate a subset of a
- VERY LARGE database. The SET FILTER TO command could be used,
- but it is very very slow when used with large databases.
-
- When I use the term large, I mean thousands of records.
- For my personal needs, the files ranged from 4,000 to 217,000 records.
-
- To get around this problem a partial index can be built. This
- index contains only the pointers to the records you want, thus the
- index is small. The drawback is that it does take time to
- create the index file, and you must have the memory available to build
- the index.
-
- The time needed to create the index file is very small. I would
- guesstimate that the time needed to create a partial index of "n"
- records is equal to less than twice the time needed to index a
- database with "n" records. So time is not an issue.
-
- The memory needed to generate an index may not be a problem to most
- users. But for those of us who use as much of the free pool as we
- can, memory is an issue. The only suggestion I have is to use
- expanded memory to hold the index tables. For those of us with AT
- machines and the standard 384K + of extended memory, use a DOS
- device driver to emulate expanded memory. This is usually the VMEM.SYS
- file. When expanded memory is available, Clipper will automatically
- move the indexing tables from standard memory into expanded memory.
- There is no need to use a SET CLIPPER environmental variable.
-
-
- mplementation
- ==============
- Partial indexing is implemented through a Clipper procedure, using
- the Clipper INDEX command, so the index file is Clipper compatable.
-
- You ask, "Isn't there a better way?", and I say to you, probably,
- but so what. I have called Nantucket support a bazillion times, to
- ask how to create a mini index, and no one knows how. There is a
- file in the NANTUCKET forum called SUBNTX.ZIP, that contains a C
- routine and some documentation, but this guy wants money before he
- will let you get at the usable code. Screw that idea.
-
- The implementation of the PARTINDX procedure was built on an idea
- by Ira Emus. I was lucky enough to find his example in the NANTUCKET
- forum, under the file name INDEX.ZIP . There was one flaw in his
- example. When using his "Partial3" function, the 1st record in the
- array is always lost. This is due to the fact that Clipper evaluates
- the INDEX expression before actually skipping through the database
- and creating the index tables. This flaw has been repaired in PARTINDX.
-
- The documentation on partial indexing by Ira Emus, INDEX.TXT, is included
- with this archive. Please read it to learn more about partial indexing.
-
-
- Brass tacks
- ===========
- The PARTINDX.prg is about 140 lines long, less the comments about 50
- lines long. The PARTINDX.obj is about 1677 bytes, less if you compile
- without line numbers.
-
- You will notice that the code for displaying status has been commented
- out. You may choose to show status or not show status. The comments
- are left there as an example of where to put the status displays.
-
- The example and usage of PARTINDX.prg is in the header of the file.
- Read the NOTE: and Example: areas carefully.
-
-
- Common problems
- ===============
- 1. Problem: Seek fails, but dbedit shows record.
- Reason.: The index expression (first parameter) was invalid.
-
- 2. Problem: DBU or other programs display "UNKNOWN IDENTIFIER xFAKEOUT".
- Reason.: 1. PARTINDX failed to rewrite the .ntx header information.
- User did not specifically specify the .ntx extention
- when naming the partial index (second parameter).
- Used "bob" instead of "bob.ntx".
- 2. Partial index is open in some other area, PARTINDX failed
- to exclusively open the partial index file for header
- rewrite.
-
- 3. Problem: Index has 0, or not enough records.
- Reason.: 1. The &KeyExpr and KeyValue expressions are never equal.
- 2. The optional UserFilter is never true.
- 3. The source database was not indexed on a key value.
-
- 4. Problem: There is always 1 record in the index that does not fit
- the KeyExpr and KeyValue criteria.
- Reason.: PARTINDX will 99% of the time insert 1 bogus record, this
- is actaully the last record in the database. The only
- way to get around this is to use the SET FILTER command.
- Don't worry, this SET FILTER will be fast.