pg.ddx.io pgsql-bugs@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Upsert functions spinlock when doing insert first. 2+ messages / 2 participants [nested] [flat]
* Upsert functions spinlock when doing insert first. @ 2015-05-27 21:39 Porte, Alexander <Alexander.Porte@agilysys.com> 2015-05-28 00:56 ` Re: Upsert functions spinlock when doing insert first. Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 1 reply; 2+ messages in thread From: Porte, Alexander @ 2015-05-27 21:39 UTC (permalink / raw) To: pgsql-bugs PostgreSQL version: 9.4.1 Operating system: CentOS 6.6 We have simple upsert functions part of our ETL process. These upsert functions execute an insert and update from staging to datawarehouse tables and finally mark all these staged rows as processed, all within the same transaction. In our tests and production we have encountered problems where these functions get stuck at full CPU with zero disk I/O. We were able to repro the problem on small dataset (<100'000 rows) with a single thread. We fiddled with settings following best practices, adding large amount of memory, increasing WAL segments, etc... to no avail. We identified the problem to be the update statement even though our tests insert tens of thousands of rows (millions in production) but only update a handful of rows each time. We thought it might have been a bad query plan due to outdated statistics but a full analyze doesn't fix the issue, sometime a postgresql restart fixes it but not always. We might have identified a work around by having the update be done first followed by the insert which is semantically equivalent as they do not operate on the same rows. This has been the only reliable fix to avoid this problem. However this is not a fix and it is concerning to us as it is such a simple use case. - Upsert function: http://pgsql.privatepaste.com/a547f35aa0 - Staging Table: http://pgsql.privatepaste.com/faeafdeb3d - Datawarehouse Table: http://pgsql.privatepaste.com/07a53910e8 Thanks, Alexander Porte Sr. Director of Engineering, Analytics Agilysys, Inc.<http://www.agilysys.com/; Alexander.Porte@agilysys.com<mailto:Alexander.Porte@agilysys.com> (o) 425.378.2295 * (m) 425.638.2220 Facebook<https://www.facebook.com/Agilysys?fref=ts; | Twitter<https://twitter.com/Agilysys; | LinkedIn<http://www.linkedin.com/company/6142?trk=tyah; | Agilysys Blog<http://news.agilysys.com/; ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Upsert functions spinlock when doing insert first. 2015-05-27 21:39 Upsert functions spinlock when doing insert first. Porte, Alexander <Alexander.Porte@agilysys.com> @ 2015-05-28 00:56 ` Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 2+ messages in thread From: Tom Lane @ 2015-05-28 00:56 UTC (permalink / raw) To: Porte, Alexander <Alexander.Porte@agilysys.com>; +Cc: pgsql-bugs "Porte, Alexander" <Alexander.Porte@agilysys.com> writes: > We have simple upsert functions part of our ETL process. These upsert functions execute an insert and update from staging to datawarehouse tables and finally mark all these staged rows as processed, all within the same transaction. > In our tests and production we have encountered problems where these functions get stuck at full CPU with zero disk I/O. We were able to repro the problem on small dataset (<100'000 rows) with a single thread. We fiddled with settings following best practices, adding large amount of memory, increasing WAL segments, etc... to no avail. This is an interesting report, but you have not really provided enough detail to let anyone else reproduce the problem. Without sample data and a script for how to call the function, we're unlikely to duplicate your results. Also, as a general rule, we'd rather that supporting files were attached to the bug report, so that they get into the pgsql-bugs archives. A month from now when those privatepaste entries are gone, this report will mean nothing to anyone. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2015-05-28 00:56 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2015-05-27 21:39 Upsert functions spinlock when doing insert first. Porte, Alexander <Alexander.Porte@agilysys.com> 2015-05-28 00:56 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox