Re: optimizing Postgres queries

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Teran <david(dot)teran(at)cluster9(dot)com>
Cc: Shridhar Daithankar <shridhar_daithankar(at)myrealbox(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: optimizing Postgres queries
Date: 2004-01-05 18:52:40
Message-ID: 16230.1073328760@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

David Teran <david(dot)teran(at)cluster9(dot)com> writes:
> What we found out now is that a query with a single 'where' works fine,
> the query planer uses the index but when we have 'two' where clauses it
> does not use the index anymore:

> EXPLAIN ANALYZE SELECT columns... FROM "KEY_VALUE_META_DATA" t0 WHERE
> (t0."ID_VALUE" = 14542); performs fine, less than one millisecond.

> EXPLAIN ANALYZE SELECT columns... FROM "KEY_VALUE_META_DATA" t0 WHERE
> (t0."ID_VALUE" = 14542 OR t0."ID_VALUE" = 14550); performs bad: about
> 235 milliseconds.

Please, when you ask this sort of question, show the EXPLAIN ANALYZE
output. It is not a virtue to provide minimal information and see if
anyone can guess what's happening.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Stephan Szabo 2004-01-05 18:57:02 Re: deferred foreign keys
Previous Message David Teran 2004-01-05 18:47:28 Re: optimizing Postgres queries