Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XwrhW-0007Ud-Kc for pgsql-odbc@arkaria.postgresql.org; Fri, 05 Dec 2014 12:09:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XwrhV-0002ik-Co for pgsql-odbc@arkaria.postgresql.org; Fri, 05 Dec 2014 12:09:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XwrhO-0002V9-O0 for pgsql-odbc@postgresql.org; Fri, 05 Dec 2014 12:09:26 +0000 Received: from smtp05.smtpout.orange.fr ([80.12.242.127] helo=smtp.smtpout.orange.fr) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XwrhI-0003A9-OG for pgsql-odbc@postgresql.org; Fri, 05 Dec 2014 12:09:23 +0000 Received: from EXCH2013.mustinformatique.fr ([80.14.156.7]) by mwinf5d62 with ME id Po9J1p00M09r3GY03o9Kta; Fri, 05 Dec 2014 13:09:19 +0100 X-ME-Helo: EXCH2013.mustinformatique.fr X-ME-Auth: bXVzdC1pbmZvcm1hdGlxdWVAd2FuYWRvby5mcg== X-ME-Date: Fri, 05 Dec 2014 13:09:19 +0100 X-ME-IP: 80.14.156.7 Received: from EXCH2013.mustinformatique.fr (172.17.0.152) by EXCH2013.mustinformatique.fr (172.17.0.152) with Microsoft SMTP Server (TLS) id 15.0.913.22; Fri, 5 Dec 2014 13:09:00 +0100 Received: from EXCH2013.mustinformatique.fr ([fe80::cde4:330a:630e:e700]) by EXCH2013.mustinformatique.fr ([fe80::cde4:330a:630e:e700%12]) with mapi id 15.00.0913.011; Fri, 5 Dec 2014 13:08:41 +0100 From: Nathanael Terrien To: Alvaro Herrera CC: "pgsql-odbc@postgresql.org" Subject: Re: Exponential processing time for multiple SELECT FOR UPDATE / UPDATE in a single transaction with PostgreSQL 9.x ? Thread-Topic: [ODBC] Exponential processing time for multiple SELECT FOR UPDATE / UPDATE in a single transaction with PostgreSQL 9.x ? Thread-Index: AdAQadpRsl3uPnmvSe2SgOKYbc4NtQAEKpCAAAJZ2fA= Date: Fri, 5 Dec 2014 12:08:40 +0000 Message-ID: <15fb6aee107e469393d79dc11556f2eb@EXCH2013.mustinformatique.fr> References: <52dd07051f6b42b09328c339c7b9c5d4@EXCH2013.mustinformatique.fr> <20141205115919.GC1768@alvh.no-ip.org> In-Reply-To: <20141205115919.GC1768@alvh.no-ip.org> Accept-Language: fr-FR, en-US Content-Language: fr-FR X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.17.1.31] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-odbc Precedence: bulk Sender: pgsql-odbc-owner@postgresql.org >Exactly what version is 9.x?=20=20 9.3.3 et 9.4 RC1 -----Message d'origine----- De=A0: Alvaro Herrera [mailto:alvherre@2ndquadrant.com]=20 Envoy=E9=A0: vendredi 5 d=E9cembre 2014 12:59 =C0=A0: Nathanael Terrien Cc=A0: pgsql-odbc@postgresql.org Objet=A0: Re: [ODBC] Exponential processing time for multiple SELECT FOR UP= DATE / UPDATE in a single transaction with PostgreSQL 9.x ? Nathanael Terrien wrote: > Hi List. >=20 > Our application does something like this, through psqlodbc=A0: > ---------------------------------------------------------------------- > -------- > Open transaction (=AB=A0BEGIN=A0=BB) > FOR x TO y STEP 1 > Do Stuff > =AB=A0SELECT col1 FROM table1 WHERE condition1 FOR UPDATE=A0;=A0=BB > Do Stuff > =AB=A0UPDATE table1 SET col1=3Dz WHERE condition1=A0;=A0=BB > Do Stuff > NEXT x > End transaction (=AB=A0COMMIT=A0=BB) > ---------------------------------------------------------------------- > -------- >=20 > Against PostgreSQL 8.4=A0: no problem. > Against PostgreSQL 9.x=A0: starting at about a few hundred loops (locks),= the process slows down, and continues to slow down exponentially, until th= e COMMIT happens. Exactly what version is 9.x? We solved a number of issues in FOR UPDATE lo= cking in early 9.3 minor releases; these should all be fixed in 9.3.5. You might be running into the problem supposedly fixed by the below commit,= but it'd imply you're on 9.3.2 or earlier, which is unadvisable because of= other data-eating bugs: commit 0bc00363b9b1d5ee44a0b25ed2dfc83f81e68258 Author: Alvaro Herrera Date: Fri Dec 13 17:16:25 2013 -0300 Rework MultiXactId cache code =20=20=20=20 The original performs too poorly; in some scenarios it shows way too high while profiling. Try to make it a bit smarter to avoid excessive cosst. In particular, make it have a maximum size, and have entries be sorted in LRU order; once the max size is reached, evict the oldest entry to avoid it from growing too large. =20=20=20=20 Per complaint from Andres Freund in connection with new tuple freezing code. Now that I think about this, maybe the cache in your case is not being usef= ul for some reason or other, and it's causing more of a slowdown. Is this plpgsql? If so, do you have EXCEPTION blocks in plpgsql code? Maybe SAVEPOINTs somewhere? (Does the ODBC driver create SAVEPOINTs automatically?) --=20 =C1lvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --=20 Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc