![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
Greetings all. I think I've stumbled onto a way to speed up queries, but am looking for a second opinion. I have a table with several secondary indexes, one of which contains the 'Name' & 'Key' fields. I want to perform a generic match on the 'Name' field, to return all rows that have Name = "..Jim..". If I perform my query on the DB file, it will open & search the entire table, ignoring the 2nd index because of the wildcards. If I perform my query directly against the appropriate XG* file, it will perform the query on a 'mini-table' of just the Name & Key columns, which should be much smaller than the entire DB table. Does this make sense? For example: Query Customer.XG1 | Key | Name | | Check | CheckPlus ..Jim.. | endQuery Note that I tried to open a tcursor against the 'Customer.XG1' file & it wouldn't let me. The query engine must work differently. Extra credit: by doing a enumIndexStruct on the table, does the iIndexID column map directly to the 'XG*' name, as 'X' + string(hex(iIndexID + 1))? I'm guessing this is the case, because the iIndexID values start with 256 and go up by 1 for each additional index. Thanks, Jim Moseley |
#12
| |||
| |||
|
|
There are operations that don't work when applied on an index file. |
#13
| |||
| |||
|
|
Anders, Imagine a 100MB file on network server. With a 500k index file. This was exactly my problem. One of my clients had a 20MB Customer table, whereas all others have under 1MB. Their network is dying, and I'm trying to speed it up. Sorry I didn't post this number earlier, but I didn't have an exact size on the XG1 file. How about a tcursor then? Will a scan of all records eventually bring the enterie table over the network, even the columns that is not refered to by the tcursor? Sadly, you can't open a tcursor on the XG1 directly - it gives a message 'Table is not indexed' (ironically). If you open a tcursor on the base table, it will 'pre-fetch' 8 pages based on the block size. Then, as you jump around the table, it will grab whatever pages are needed. So, if you scan the entire table, you'll need all 20MB in my above example. One other benefit to the XG1: if you open a tcursor on a table, it will open all table lookups also. I'm assuming it doesn't want to slow down tc.edit() (or the f9 key), so it always assumes you'll edit. I'm not sure, but these might also get 8 pages 'pre-fetched'. I'm getting somewhat proficient with the free WireShark network monitor. http://www.wireshark.org I you have speed issues, this is the best tool I've found. It replaced Ethereal a while back. Thanks, Jim Moseley |
#14
| |||
| |||
|
#15
| |||
| |||
|
#16
| |||
| |||
|
|
Bertil, Well, so much for brilliant ideas! One of my clients has been getting 'Lock Time Out' errors since I put my new code in. Since these are maintained indexes, there must be a conflict when someone updates a row on the table (or just the 2nd index columns?). Isn't there a way to ignore table changes when running a query? Thanks, Jim Moseley |
![]() |
| Thread Tools | |
| Display Modes | |
| |