could primary key slow down your query?
Posted in 1999
Topics: General Discussion
hi all: I have a table with 10 fields. I load it up with 1 gig of data. I did a select query on it with 3 critierias. Then, I added a primary key to the first 6 fields, did the same query again, guess what, the second time took longer! (about 25% longer) The 3 critierias in the query correspond to 3 fields in the primary key. Is there any reason for this? Appreciate any inputs. thanks. yan
Yan Zhu wrote: > > hi all: > I have a table with 10 fields. I load it up with 1 gig of data. I > did a select query on it with 3 critierias. Then, I added a primary key > to the first 6 fields, did the same query again, guess what, the second > time took longer! (about 25% longer) > The 3 critierias in the query correspond to 3 fields in the primary > key. > Is there any reason for this? Not enough information, but gathering it could give you the answer you seek. Run the queries again with SET EXPLAIN ON and compare the output. If you cannot figure it out post the sqexplain.out file and the table's schema and someone will look at it. Art S. Kagel
If you didn't update statistics "medium" on the table and/or key fields, then do that and try again. Other than that, I don't know of any reason why an exact key match wouldn't get you near instantaneous response time. Let me know what you find. David M. (Albany, NY)