Re: A qsort template

Поиск
Список
Период
Сортировка
От John Naylor
Тема Re: A qsort template
Дата
Msg-id CAFBsxsEJxfQcMfCjGi+Vbkqf0SnpCW65vfh4SMySYo8NaBTLhg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: A qsort template  (David Rowley <dgrowleyml@gmail.com>)
Ответы Re: A qsort template  (David Rowley <dgrowleyml@gmail.com>)
Список pgsql-hackers
On Tue, Apr 12, 2022 at 7:58 AM David Rowley <dgrowleyml@gmail.com> wrote:
>
> I've attached the patch I tested. It was thrown together very quickly
> just to try out the performance. If it's interesting I can polish it
> up a bit. If not, I didn't waste too much time.

@@ -959,6 +965,10 @@ tuplesort_begin_batch(Tuplesortstate *state)

  state->tapeset = NULL;

+ /* check if specialized sorts can skip calling the tiebreak function */
+ state->oneKeySort = state->nKeys == 1 &&
+ !state->sortKeys[0].abbrev_converter;
+

IIUC, this function is called by tuplesort_begin_common, which in turn
is called by tuplesort_begin_{heap, indexes, etc}. The latter callers
set the onlyKey and now oneKeySort variables as appropriate, and
sometimes hard-coded to false. Is it intentional to set them here
first?

Falling under the polish that you were likely thinking of above:

We might rename oneKeySort to skipTiebreaker to avoid confusion.
SInce the test for these variable is the same, we could consolidate
them into a block and reword this existing comment  (which I find a
little confusing anyway):

/*
* The "onlyKey" optimization cannot be used with abbreviated keys, since
* tie-breaker comparisons may be required.  Typically, the optimization
* is only of value to pass-by-value types anyway, whereas abbreviated
* keys are typically only of value to pass-by-reference types.
*/

I can take a stab at this, unless you had something else in mind.

-- 
John Naylor
EDB: http://www.enterprisedb.com



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

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: pg_walcleaner - new tool to detect, archive and delete the unneeded wal files (was Re: pg_archivecleanup - add the ability to detect, archive and delete the unneeded wal files on the primary)
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Postgres perl module namespace