Re: SELECT from a set of values really slow? - Mailing list pgsql-general

From Tom Lane
Subject Re: SELECT from a set of values really slow?
Date
Msg-id 13065.1097438410@sss.pgh.pa.us
Whole thread Raw
In response to SELECT from a set of values really slow?  (Tim Smith <reply_in_group@mouse-potato.com>)
Responses Re: SELECT from a set of values really slow?  (Pierre-Frédéric Caillaud<lists@boutiquenumerique.com>)
List pgsql-general
Tim Smith <reply_in_group@mouse-potato.com> writes:
>     SELECT id FROM bench WHERE data IN ('X', 'Y')

> To my surprise, when I tried this trick with PostgreSQL, it did not
> speed things up.  In fact, it *massively* slowed down--it only is
> getting 13 selects in 3 seconds, searching for two at a time.

> What's going on here?

Likely it's switching from index to sequential scan because of a poor
estimate of how many rows will be returned.  Have you ever ANALYZEd
the test table?  Without either ANALYZE stats or a unique index,
the planner will certainly not think that the column is unique.

            regards, tom lane

pgsql-general by date:

Previous
From: Gaetano Mendola
Date:
Subject: Re: VACUUM FULL on 24/7 server
Next
From: "m.b."
Date:
Subject: Get Postgre Status and Information