Re: SELECT from a set of values really slow?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tim Smith <reply_in_group(at)mouse-potato(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SELECT from a set of values really slow?
Date: 2004-10-10 20:00:10
Message-ID: 13065.1097438410@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tim Smith <reply_in_group(at)mouse-potato(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2004-10-11 06:50:18 Re: OT moving from MS SQL to PostgreSQL
Previous Message Vitaly Belman 2004-10-10 19:22:53 Re: