Re: slow IN() clause for many cases - Mailing list pgsql-hackers

From Greg Stark
Subject Re: slow IN() clause for many cases
Date
Msg-id 8764ryfmav.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: slow IN() clause for many cases  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: slow IN() clause for many cases
List pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> writes:

> Greg Stark <gsstark@mit.edu> writes:
> > I would fear queries like
> 
> >  SELECT * from tab WHERE x IN (1,2,3) LIMIT 1
> 
> > Which ought to be instantaneous would become potentially slow.
> 
> Why?  They certainly wouldn't be any slower than they are now.

Well currently they get rewritten to use OR which does a single index scan
which I assumed returned rows as soon as it finds them like it does for
regular range lookup index scans. Is that assumption wrong?

The bitmap scan has to traverse all the index entries for matching records
before it can fetch the first record. So it wouldn't be a fast-start plan. Not
as bad as performing a sort step or anything like that of course.

-- 
greg



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: A costing analysis tool
Next
From: Martijn van Oosterhout
Date:
Subject: Re: A costing analysis tool