From: Bryan on 29 May 2010 16:45
Christian Heimes wrote:
[D'Arcy J.M. Cain had written:]
> > SELECT * FROM NumberOfPets
> > WHERE name IN (SELECT name FROM CatLovers) OR
> > name IN (SELECT name FROM DogLovers)
> > ORDER BY name;
> A good way is to use SQL with JOINs instead of horrible nested
Do show us your join that makes D'Arcy's nested select horrible by
> Although SQL is declarative, you shouldn't make the work of the query
> optimizer so hard.
You're not doing the query optimizer any favors. It can normalize the
query to the same thing either way, so we might as well write it to be
readable by people. I can read D'Arcy's at a glance.
From: D'Arcy J.M. Cain on 29 May 2010 19:00
On Sat, 29 May 2010 13:45:37 -0700 (PDT)
Bryan <bryanjugglercryptographer(a)yahoo.com> wrote:
> You're not doing the query optimizer any favors. It can normalize the
> query to the same thing either way, so we might as well write it to be
> readable by people. I can read D'Arcy's at a glance.
Assuming that you are running a decent *cough* PostgreSQL *cough*
database engine. Readable is good. If you have a problem with your
queries chances are that reorganizing your data or adding proper
indexes will do more for you than contorted SQL will.
D'Arcy J.M. Cain <darcy(a)druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.