Re: Avoid computing ORDER BY junk columns unnecessarily

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: Avoid computing ORDER BY junk columns unnecessarily
Дата
Msg-id dd7eed69-4e99-4da2-87a8-2a94b35309fa@iki.fi
обсуждение исходный текст
Ответ на Re: Avoid computing ORDER BY junk columns unnecessarily  (Xiaoran Wang <fanfuxiaoran@gmail.com>)
Ответы Re: Avoid computing ORDER BY junk columns unnecessarily  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 22/12/2023 11:05, Xiaoran Wang wrote:
> I haven't dug into your patch yet, but for this problem, I have another 
> idea.
> -------
> explain verbose
>    select foo from mytable order by sha256(bar::bytea);
> 
>                                              QUERY PLAN
> 
> ------------------------------------------------------------------------------------------------
>    Index Scan using mytable_sha256_idx on public.mytable
> (cost=0.29..737.28 rows=10000 width=64)
>      Output: foo, sha256((bar)::bytea)
> (2 rows)
> 
> The index is used to satisfy the ORDER BY, but the expensive ORDER BY
> expression is still computed for every row, just to be thrown away by
> the junk filter.
> ------
> How about adding the orderby column value  in 'xs_heaptid' with the 
> 'xs_heaptid'
> together? So that we can use that value directly instead of computing it 
> when using
> an index scan to fetch the ordered data.

Hmm, so return the computed column from the index instead of recomputing 
it? Yeah, that makes sense too and would help in this example. It won't 
help in all cases though, the index might not store the original value 
in the first place.

-- 
Heikki Linnakangas
Neon (https://neon.tech)




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

Предыдущее
От: shveta malik
Дата:
Сообщение: Re: Synchronizing slots from primary to standby
Следующее
От: Laurenz Albe
Дата:
Сообщение: Re: Set log_lock_waits=on by default