Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Databases General > One example of ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 9 Topic 3196 of 3295
Post > Topic >>

One example of a slow query.

by "David Cressey" <cressey73@[EMAIL PROTECTED] > Jun 24, 2008 at 06:18 PM

At one site,  I managed to verify that one of these two queries ran 10 to
100 times faster than the other:

select * from customers
   where country = 'US' and
              state = 'TX' and
              City = 'Dallas'

select * from customers
   where  state = 'TX' and
              City = 'Dallas'


I expected the first one to run much faster  and it did.  Why?  Because
there was an index with a compound index key,  namely country, state, and
city.  In the second case the poor optimizer was faced with walking the
index instead of a quick lookup,  as it could do in the first case.

But the clever programmers had used the second form,  because they knew
that
all the customers were in US,  and they wanted to keep things simple for
the
DBMS.

Not only were they running way too slow,  but also,  they had written code
that could break when the user community decided to extend the customer
base
to other countries.

This is just one example out of hundreds of possible examples,  where the
programmers code strangely in order to speed things up,  and instead they
slow things down.
 




 9 Posts in Topic:
One example of a slow query.
"David Cressey"  2008-06-24 18:18:08 
Re: One example of a slow query.
David Segall <david@[E  2008-06-25 09:13:38 
Re: One example of a slow query.
"Roy Hann" <  2008-06-25 11:12:55 
Re: One example of a slow query.
"Arved Sandstrom&quo  2008-06-25 11:55:34 
Re: One example of a slow query.
Thomas Kellerer <YQDHX  2008-06-25 14:16:23 
Re: One example of a slow query.
"David Cressey"  2008-06-25 14:13:42 
Re: One example of a slow query.
"David Cressey"  2008-06-25 14:10:37 
Re: One example of a slow query.
Ed Prochak <edprochak@  2008-06-25 05:09:24 
Re: One example of a slow query.
Ed Prochak <edprochak@  2008-06-25 05:16:06 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 9:30:49 CST 2008.