Re: optimizing Postgres queries - Mailing list pgsql-performance

From Tom Lane
Subject Re: optimizing Postgres queries
Date
Msg-id 20540.1073329548@sss.pgh.pa.us
Whole thread Raw
In response to Re: optimizing Postgres queries  (David Teran <david.teran@cluster9.com>)
Responses Re: optimizing Postgres queries
List pgsql-performance
David Teran <david.teran@cluster9.com> writes:
> explain result from second query:

> Seq Scan on "KEY_VALUE_META_DATA" t0  (cost=0.00..2671.16 rows=931 width
> =1068) (actual time=122.669..172.179 rows=25 loops=1)
>   Filter: (("ID_VALUE" = 21094) OR ("ID_VALUE" = 21103))

The problem is evidently that the row estimate is so far off (931
estimate vs 25 actual).  Have you done ANALYZE or VACUUM ANALYZE
on this table recently?  If you have, I'd be interested to see the
pg_stats row for ID_VALUE.  It might be that you need to increase
the statistics target for this table.

            regards, tom lane

pgsql-performance by date:

Previous
From: John Siracusa
Date:
Subject: Select max(foo) and select count(*) optimization
Next
From: David Teran
Date:
Subject: Re: optimizing Postgres queries