Re: Performance degradation on concurrent COPY into a single relation in PG16.
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>,
Andres Freund <andres@anarazel.de>, Jakub Wartak <jakub.wartak@enterprisedb.com>,
Andrew Dunstan <andrew@dunslane.net>, Peter Eisentraut <peter@eisentraut.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2023-07-19T23:56:25Z
Lists: pgsql-hackers
Attachments
- pg_strtoint32_base_10_first.patch (text/plain) patch
On Wed, 19 Jul 2023 at 23:14, Dean Rasheed <dean.a.rasheed@gmail.com> wrote: > Hmm, I'm somewhat sceptical about this second patch. It's not obvious > why adding such tests would speed it up, and indeed, testing on my > machine with 50M rows, I see a noticeable speed-up from patch 1, and a > slow-down from patch 2: I noticed that 6fcda9aba added quite a lot of conditions that need to be checked before we process a normal decimal integer string. I think we could likely do better and code it to assume that most strings will be decimal and put that case first rather than last. In the attached, I've changed that for the 32-bit version only. A more complete patch would need to do the 16 and 64-bit versions too. -- setup create table a (a int); insert into a select x from generate_series(1,10000000)x; copy a to '~/a.dump'; -- test truncate a; copy a from '/tmp/a.dump'; master @ ab29a7a9c Time: 2152.633 ms (00:02.153) Time: 2121.091 ms (00:02.121) Time: 2100.995 ms (00:02.101) Time: 2101.724 ms (00:02.102) Time: 2103.949 ms (00:02.104) master + pg_strtoint32_base_10_first.patch Time: 2061.464 ms (00:02.061) Time: 2035.513 ms (00:02.036) Time: 2028.356 ms (00:02.028) Time: 2043.218 ms (00:02.043) Time: 2037.035 ms (00:02.037) (~3.6% faster) Without that, we need to check if the first digit is '0' a total of 3 times and also check if the 2nd digit is any of 'x', 'X', 'o', 'O', 'b' or 'B'. It seems to be coded with the assumption that hex strings are the most likely. I think decimals are the most likely by far. David
Commits
-
Avoid edge case in pg_visibility test with small shared_buffers
- 408209d6a9ae 16.3 landed
- 3a4837fc809a 17.0 landed
-
Fix bulk table extension when copying into multiple partitions
- 0002feb82096 16.1 landed
- 22655aa23132 17.0 landed
-
hio: Take number of prior relation extensions into account
- 82a4edabd272 17.0 landed
- d37ab378b6e7 16.0 landed
-
Fix performance regression in pg_strtointNN_safe functions
- 4e2e75cd29eb 16.0 landed
- 3845577cb55e 17.0 landed
-
Fix performance problem with new COPY DEFAULT code
- c1308ce2d922 16.0 landed
- b635ac03e802 17.0 landed
-
hio: Use ExtendBufferedRelBy() to extend tables more efficiently
- 00d1e02be249 16.0 cited
-
Add VACUUM/ANALYZE BUFFER_USAGE_LIMIT option
- 1cbbee033857 16.0 cited