Re: huge disparities in =/IN/BETWEEN performance - Mailing list pgsql-sql

From Alvaro Herrera
Subject Re: huge disparities in =/IN/BETWEEN performance
Date
Msg-id 20070209021414.GU24069@alvh.no-ip.org
Whole thread Raw
In response to Re: huge disparities in =/IN/BETWEEN performance  ("George Pavlov" <gpavlov@mynewplace.com>)
Responses Re: huge disparities in =/IN/BETWEEN performance  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
George Pavlov wrote:

> the basic question i have is fairly clear though: why saying "where x =
> 10" should be  different (in ANY cicumstance, not just mine) from saying
> "where x between 10 and 10" or from "where x in (select ... /* some
> query that returns 10 */)" ??? 

I think the principle here is that the system is not gonna waste cycles
on dumb queries.  Supposedly, morphing "foo BETWEEN 10 and 10" into
"foo=10" is not a trivial transformation, and it'd impose a planning
cost on all non-dumb BETWEEN queries.  That cost is best avoided: if you
optimize for dumb users, the smart users then want you buried because
you've lost performance doing useless work.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


pgsql-sql by date:

Previous
From: "George Pavlov"
Date:
Subject: Re: huge disparities in =/IN/BETWEEN performance
Next
From: Tom Lane
Date:
Subject: Re: huge disparities in =/IN/BETWEEN performance