![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
|
Check | CheckPlus ..Jim.. | endQuery |
#2
| |||
| |||
|
|
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..". |
#3
| |||
| |||
|
|
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 |
#4
| |||
| |||
|
|
but then you'd need to do a 2nd query to grab the remaining info you'll need, from the main table.. |
|
and, FWIW, you're still doing a dot-dot query, that has to go thru all records.. |
#5
| |||
| |||
|
|
I'm not sure but will a search like that ever be able to take advantage of an index? |
|
If your search had been for "Jim.." it would have been a different story |
#6
| |||
| |||
|
|
Steven, but then you'd need to do a 2nd query to grab the remaining info you'll need, from the main table.. My app handles this already. In this routine, all I need is a table containing the 'Key' values. If there is more than one row, I show the user a screen asking them to choose. Its DM has the Answer.db linked 1-1 to Customer.db (to show other descriptive fields). and, FWIW, you're still doing a dot-dot query, that has to go thru all records.. Exactly my point. By directly querying the Customer.XG1 file, I avoid querying Customer.DB. Since the XG1 only has 2 columns, it should be much faster than going after my 'wide' tables. Thanks, Jim Moseley |
#7
| |||
| |||
|
|
But, it will only go through all the rows of the index, not the base table. At one client, Customer.db is 650kb but Customer.XG1 is only 66kb. 10 times smaller should be 10 times faster, or more since I'm not getting network retries. |
|
Right, but I didn't want to force my users to enter data a specific way - 'Jim Moseley' or 'Moseley, Jim' or whatever. Also, it helps them if they can't remember how to spell, ie. 'McGuire' 'Maguire' 'MacGuire' can all be found with '..guire..'. |
#8
| |||
| |||
|
|
But, it will only go through all the rows of the index, not the base table. I'm certainly no expert on this but wouldn't the file size of .db file have a rather minor impact? |
#9
| |||
| |||
|
|
Imagine a 100MB file on network server. With a 500k index file. |
|
A query draws the entire table local, and THEN processes the query Which file would you prefer to bring local for the query to act on? |
#10
| |||
| |||
|
|
Imagine a 100MB file on network server. With a 500k index 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? |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |