Due to Access' lack of case sensitivity on the primary key, I need to check if a record exists before I insert a new record. Is it faster to return a count, or to return actual data from a table? I.E. which of the following queries will be faster?
Originally posted by Paul Sturrock: The only way you'll know for sure is to try both cases and see.
This is why I said "not by any really measurable amount". But COUNT should be faster and I believe is better practice in general.
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
How common is it that your id value is in use? If it's rare, I would blindly insert, then deal with the possible collision.
There is no emoticon for what I am feeling!
Tom Blough
Ranch Hand
Joined: Jul 31, 2003
Posts: 263
posted
0
Jeff,
Unfortunately, I can't rely on a collision using my key. The key is a data stamp generated from a machine on our factory floor that uses both upper and lowercase letters. Each date code is unique, but Access thinks "dqKez" is the same as "dqKeZ" as far as unique primary keys are concerned (it's not case sensitive for key comparison).
Access IS case sensitive on queries, so the work-around is check if it exists first, and add only if it does not. If the search returns the key, then I handle the exception case.