I used VALUES as a replacement for the temporary table since for this application, it is a lot more useful.

        The point is :

SELECT * FROM table WHERE value IN ( 1000 integers ) : does 1000 comparisons for each row SELECT * FROM table WHERE value IN ( VALUES (1000 integerss) ) : builds a Hash with the 1000 values and uses it to test rows, which is a lot faster if you have many values to compare with.

The first one is faster if the number of values in the IN() is small. The second one is faster if the number of values in the IN() is large.

EXPLAIN ANALYZE SELECT * FROM table JOIN test ON (table.column = test.value)

It wouldn't give the same result : both queries above remove duplicates, this one does not.

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

              http://www.postgresql.org/docs/faq

Reply via email to