Re: Efficiency Issue with "SELECT IN (..)" and "SELECT .. OR .."

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mike Winter <mike(dot)winter(at)frontlogic(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Efficiency Issue with "SELECT IN (..)" and "SELECT .. OR .."
Date: 2003-05-16 19:25:22
Message-ID: 29030.1053113122@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Mike Winter <mike(dot)winter(at)frontlogic(dot)com> writes:
> If the "IN (1, 2, 3, 6, ..., n)" clause is big enough, the
> database will actually throw an error saying "Recursive Depth
> Exceeded" or something similar and not complete the query.

Would it perhaps be saying "out of free buffers: time to abort!" ?
If so, you're probably running into this bug, which was introduced
(by me :-() in 7.3:
http://archives.postgresql.org/pgsql-hackers/2003-03/msg00939.php
There is a fix in place for 7.3.3.

> It looks to me like the query parser is recursively calling
> an index scan for each row in the 'IN' clause rather than just
> doing one index scan that it seems it should be.

It is performing one index search per target value, yes, but not
recursively. That's what it's supposed to do.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Mike Winter 2003-05-16 19:28:31 Re: Efficiency Issue with "SELECT IN (..)" and "SELECT .. OR
Previous Message Tom Lane 2003-05-16 19:13:48 Re: "deadlock detected" documentation