From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> |
Cc: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Денис Смирнов <darthunix(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Use virtual tuple slot for Unique node |
Date: | 2023-10-19 10:56:14 |
Message-ID: | CAApHDvq3W0mvKTMe9r032Jbzb1E8dwE1SCCZ1WnkuLvc45r8wg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, 19 Oct 2023 at 22:29, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> It's hard to imagine why there would be a slowdown as this query uses
> a TTSOpsMinimalTuple slot type in the patch and the unpatched version.
I shrunk down your table sizes to 10k rows instead of 1 million rows
to reduce the CPU cache pressure on the queries.
I ran pgbench for 1 minute on each query and did pg_prewarm on each
table. Here are the times I got in milliseconds:
Query master Master + 0001 compare
Q1 2.576 1.979 130.17%
Q2 9.546 9.941 96.03%
Q3 9.069 9.536 95.10%
Q4 7.285 7.208 101.07%
Q5 7.585 6.904 109.86%
Q6 162.253 161.434 100.51%
Q7 62.507 58.922 106.08%
I also noted down the slot type that nodeUnique.c is using in each of
the queries:
Q1 TTSOpsVirtual
Q2 TTSOpsVirtual
Q3 TTSOpsVirtual
Q4 TTSOpsMinimalTuple
Q5 TTSOpsVirtual
Q6 TTSOpsMinimalTuple
Q7 TTSOpsMinimalTuple
So, I'm not really expecting Q4, Q6 or Q7 to change much. However, Q7
does seem to be above noise level faster and I'm not sure why.
We can see that Q2 and Q3 become a bit slower. This makes sense as
tts_virtual_materialize() is quite a bit more complex than
heap_copy_minimal_tuple() which is a simple palloc/memcpy.
We'd likely see Q2 and Q3 do better with the patched version if there
were more duplicates as there'd be less tuple deforming going on
because of the virtual slots.
Overall, the patched version is 5.55% faster than master. However,
it's pretty hard to say if we should do this or not. Q3 has a mix of
varlena and byval types and that came out slower with the patched
version.
I've attached the script I used to get the results and the setup,
which is just your tables shrunk down to 10k rows.
David
Attachment | Content-Type | Size |
---|---|---|
uniquebench.sh.txt | text/plain | 850 bytes |
setup.sql | application/octet-stream | 643 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Marko Tiikkaja | 2023-10-19 11:03:42 | Re: [HACKERS] Allow INSTEAD OF DELETE triggers to modify the tuple for RETURNING |
Previous Message | Hayato Kuroda (Fujitsu) | 2023-10-19 10:45:53 | RE: [PoC] pg_upgrade: allow to upgrade publisher node |