python-3.xindexingdbf

Python Decrease dbf Index Time


Attempting to decrease the time it takes to index a dfb file. I am using the following to create an index:

bid_index=table.create_index(lambda rec: rec.bidid)

This works but seems to take very long time. I have not actually timed the process time, but I can count seconds until the process returns a result. The index returns approx 40,000 plus records. Just wondering if there is a faster way to search dbf for a particular value. If there is no way to speed up the indexing, anyway to break once the value is found while the indexing is taking place?


Solution

  • Remember that dbf is a pure-Python program. This means there are no low-level routines to speed up certain actions. In order to create an index every single record is scanned to build the key. This is only beneficial if you are going to do at least a couple searches. If you are only doing one search with that type of key, just scan with a for loop.