Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a program that has a lookup, my filter is Surname House Number Town Postcode using a MDB with 600000 more r less records. I created a code that uses the SELECT statement but it takes 8 or more seconds to view all queried data from a list. Someone suggest that use the RecordSet.Seek.

This Record is been parse from a text file to MDB

This is the table layout using the SELECT statement

ID | Surname | House Number | Town | Postcode
1  |  Name   |   10         | Town | 2121
2  |  Last   |   50         | AAA  | 2121
3  |  Surname|   101        | BBB  | 3030
4  |  Name   |   10         | Town | 2121


If I use the RecordSet.Seek, I will add another table for filter data

ID | Surname | House Number | Town | Postcode
1  |  Name   |   10         | Town | 2121
2  |  Last   |   50         | AAA  | 2121
3  |  Surname|   101        | BBB  | 3030
4  |  Name   |   10         | Town | 2121


Filter         | IDS
Name10Town2121 | 1,4


Now when I execute it to the program I will Seek the Filter then when a record is found, I will get the IDS then split and loop the IDS value and Seek the ID one by one.

My question is what is more faster, using the SELECT Statement or using RecordSet.Seek.

Also I dont know how to use Seek method so I ask here first.
Posted

RecordSet.Seek will give you the first record found not all the records, so this is better if you want to find one item. To get more you have to repeatedly call again.

If you want more than one record then the SQL select is better and your code is more standard for the future when you have to upgrade to a RDBM.

If the query is slow try compacting the MDB file and reapplying indexes.
 
Share this answer
 
Comments
hansoctantan 8-Sep-11 6:54am    
What do you mean reapplying indexes?
Agree with Mehdi. I'd say SELECT is a better way to go. Access is better optimized to be used SQL when a table contains 'lots' of data. Seek is basically just a cursor-like operation looping through the data.

If the query is slow, create proper indexes on the table. For example, if you often query using the Id field create an index on that field. For more info see: http://msdn.microsoft.com/en-us/library/bb177891(v=office.12).aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900