Re: optimizing Postgres queries - Mailing list pgsql-performance

From David Teran
Subject Re: optimizing Postgres queries
Date
Msg-id 9CC6A792-3FAF-11D8-A528-000A95A6F0DC@cluster9.com
Whole thread Raw
In response to Re: optimizing Postgres queries  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: optimizing Postgres queries  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-performance
Hi Tom,

> It's worth pointing out that this problem is fixed (at long last) in
> CVS tip.  Ypu probably shouldn't expend large amounts of effort on
> working around a problem that will go away in 7.5.
>
We have now changed the definition to integer, this will work for some
time. We are currently evaluating and have several production database
we might switch in some time.

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.

I tried to change the second one to use IN but this did not help at
all. Am i doing something wrong? I have an index defined like this:

CREATE INDEX key_value_meta_data__id_value__fk_index ON
"KEY_VALUE_META_DATA" USING btree ("ID_VALUE");

Regards David


pgsql-performance by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: deferred foreign keys
Next
From: Tom Lane
Date:
Subject: Re: optimizing Postgres queries