Re: huge disparities in =/IN/BETWEEN performance

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: George Pavlov <gpavlov(at)mynewplace(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-sql(at)postgresql(dot)org
Subject: Re: huge disparities in =/IN/BETWEEN performance
Date: 2007-02-09 02:14:14
Message-ID: 20070209021414.GU24069@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2007-02-09 03:50:05 Re: huge disparities in =/IN/BETWEEN performance
Previous Message George Pavlov 2007-02-09 02:03:40 Re: huge disparities in =/IN/BETWEEN performance