Re: GUCs to control abbreviated sort keys

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: GUCs to control abbreviated sort keys
Date: 2023-01-27 14:14:34
Message-ID: CA+TgmoZ3FUJFJ+pfzZ8gPZiPHXKU01mBKBuWcc8YGPScjYGTxg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 25, 2023 at 4:16 PM Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
> $ perl text_generator.pl 10000000 10 > /tmp/strings.txt
>
> CREATE TABLE s (t TEXT);
> COPY s FROM '/tmp/strings.txt';
> VACUUM FREEZE s;
> CHECKPOINT;
> SET work_mem='10GB';
> SET max_parallel_workers = 0;
> SET max_parallel_workers_per_gather = 0;
>
> SET sort_abbreviated_keys = false;
> EXPLAIN ANALYZE SELECT t FROM s ORDER BY t COLLATE "en-US-x-icu";
> -- 20875ms
>
> SET sort_abbreviated_keys = true;
> EXPLAIN ANALYZE SELECT t FROM s ORDER BY t COLLATE "en-US-x-icu";
> -- 22931ms
>
> Regression for abbreviated keys optimization in this case: 9.8%

That's interesting. Do you have any idea why this happens?

I've been a bit busy the last few days so haven't had a chance to look
at the test case until now. It seems like it's just a lorum ipsum
generator, except that each line is made to contain a random number of
words, and certain letters from the Latin alphabet are replaced with
other symbols. But why is that a problem for abbreviated keys? The
most obvious way for things to go wrong is for the first 8 bytes of
the strxfrm() blob to be very low-entropy, but it's not really clear
to me what about your test case would make that more likely. I guess
another explanation could be if having a few non-ASCII characters
mixed into the string makes strxfrm() a lot slower.

--
Robert Haas
EDB: http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2023-01-27 14:23:03 Re: [PATCH] Reuse Workers and Replication Slots during Logical Replication
Previous Message Mikhail Gribkov 2023-01-27 14:00:11 Re: GUC for temporarily disabling event triggers