On Wed, Jan 25, 2023 at 4:16 PM Jeff Davis <pg...@j-davis.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