Re: IN list processing performance (yet again)
Christopher Kings-Lynne <chriskl@familyhealth.com.au>
From: "Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
To: "Dave Tenny" <tenny@attbi.com>, "Bruno Wolff III" <bruno@wolff.to>
Cc: "Andreas Pflug" <Andreas.Pflug@web.de>, <pgsql-performance@postgresql.org>
Date: 2003-05-29T01:53:55Z
Lists: pgsql-performance
> Also, IN (subquery) is a known performance problem in PGSQL, at least if the subquery is going to return > many rows. > It's too bad, since I'm rather fond of subqueries, but I avoid them like the plague in PostgreSQL. You're not really using a subquery - really just a long list of integers. Subqueries are lightning fast, so long as you conver to the EXISTS form: SELECT * FROM tab WHERE id IN (SELECT id2 FROM tab2); converts to: SELECT * FROM tab WHERE EXISTS (SELECT id2 FROM tab2 WHERE id2=id); Chris