IN statement performance in PostgreSQL (and in general)
- by Vasil
I know this has probably been asked before, but I can't find it with SO's search.
Lets say i've TABLE1 and TABLE2, who should I expect the performance of a query such as this:
SELECT * FROM TABLE1 WHERE id IN SUBQUERY_ON_TABLE2;
as the number of rows in TABLE1 and TABLE2 grow and id is a primary key on TABLE1.
Yes, I know using IN is such a n00b mistake, but TABLE2 has a generic relation (django generic relation) to multiple other tables so I can't think of another way to filter the data. At what (aproximate) ammount of rows in TABLE1 and TABLE2 should I expect to notice performance issues because of this? Will performance degrade linearly, exponentially etc. depending on the number of rows?