Search Postgresql Archives

Re: Have I b0rked something? Slow comparisons on "where x in (...)"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





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.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux