Re: Binary search in ScalarArrayOpExpr for OR'd constant arrays

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: Binary search in ScalarArrayOpExpr for OR'd constant arrays
Дата
Msg-id 20200423223544.xnjdounoflxq4lgv@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: Binary search in ScalarArrayOpExpr for OR'd constant arrays  (David Rowley <dgrowleyml@gmail.com>)
Список pgsql-hackers
Hi,

On 2020-04-24 10:09:36 +1200, David Rowley wrote:
> If single comparison for a binary search costs about the same as an
> equality check, then wouldn't the crossover point be much lower than
> 64?

The costs aren't quite as simple as that though. Binary search usually
has issues with cache misses: In contrast to linear accesses each step
will be a cache miss, as the address is not predictable; and even if the
CPU couldn't predict accesses in the linear search case, often multiple
entries fit on a single cache line. Additionally out-of-order execution
is usually a lot more effective for linear searches (e.g. the next
elements can be compared before the current one is finished if that's
what the branch predictor says is likely).

Greetings,

Andres Freund



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

Предыдущее
От: David Rowley
Дата:
Сообщение: Re: Binary search in ScalarArrayOpExpr for OR'd constant arrays
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: 2pc leaks fds