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

Поиск
Список
Период
Сортировка
От Listmail
Тема Re: Have I b0rked something? Slow comparisons on "where x in (...)"
Дата
Msg-id op.trsscziuzcizji@apollo13
обсуждение исходный текст
Ответ на Re: Have I b0rked something? Slow comparisons on "where x in (...)"  (Alban Hertroys <alban@magproductions.nl>)
Список pgsql-general

    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.

В списке pgsql-general по дате отправления:

Предыдущее
От: "Paolo Saudin"
Дата:
Сообщение: R: R: Postgres 8.3-dev
Следующее
От: Kevin Murphy
Дата:
Сообщение: Permission denied to create database