Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Xwsda-0001Rl-Bg for pgsql-odbc@arkaria.postgresql.org; Fri, 05 Dec 2014 13: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 1XwsdY-0001DL-Vg for pgsql-odbc@arkaria.postgresql.org; Fri, 05 Dec 2014 13:09:33 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XwsdY-0001DE-1U for pgsql-odbc@postgresql.org; Fri, 05 Dec 2014 13:09:32 +0000 Received: from smtp05.smtpout.orange.fr ([80.12.242.127] helo=smtp.smtpout.orange.fr) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XwsdU-0003qy-6I for pgsql-odbc@postgresql.org; Fri, 05 Dec 2014 13:09:30 +0000 Received: from EXCH2013.mustinformatique.fr ([80.14.156.7]) by mwinf5d62 with ME id Pp9P1p00G09r3GY03p9Pn8; Fri, 05 Dec 2014 14:09:26 +0100 X-ME-Helo: EXCH2013.mustinformatique.fr X-ME-Auth: bXVzdC1pbmZvcm1hdGlxdWVAd2FuYWRvby5mcg== X-ME-Date: Fri, 05 Dec 2014 14:09:26 +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 14:09:23 +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 14:09:22 +0100 From: Nathanael Terrien To: Heikki Linnakangas , 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: AdAQadpRsl3uPnmvSe2SgOKYbc4NtQAEKpCAAAA8WQAAAo9JoA== Date: Fri, 5 Dec 2014 13:09:22 +0000 Message-ID: References: <52dd07051f6b42b09328c339c7b9c5d4@EXCH2013.mustinformatique.fr> <20141205115919.GC1768@alvh.no-ip.org> <54819FAC.7030103@vmware.com> In-Reply-To: <54819FAC.7030103@vmware.com> 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 I reconfigured the ODBC connection setting (through the driver's windows in= terface) and set the protocol to "7.4-1" and it solved the slowdown problem. (w00t!) Which is fine by us as it was the default behavior before (I guess), and th= at's how our application is designed to handle transaction.=20 Thank you, guys :) The test case is pretty simple : -------------------------------------------------------- -- create and populate table CREATE TABLE _slowlocks ( lib character varying(50), numbers integer ); INSERT INTO _slowlocks VALUES ('one',0),('two',0),('three',0); ---------------------------------------------------------- --- In any language/program, run something like this :=20 --------------- ExecuteSQL("BEGIN;") FOR(i=3D0,i++,i<1000) ExecuteSQL("SELECT numbers FROM _slowlocks WHERE lib=3D'two' FOR UPDATE;") ExecuteSQL("UPDATE _slowlocks SET numbers=3D numbers +1 WHERE lib=3D'two';= ") NEXT i ExecuteSQL("COMMIT;") ---------------------------------------------------------- With protocol set to "7.4-2", it took 1 minute and 11 seconds With protocol set to "7.4-1", it took 1.2 second ... -----Message d'origine----- De=A0: Heikki Linnakangas [mailto:hlinnakangas@vmware.com]=20 Envoy=E9=A0: vendredi 5 d=E9cembre 2014 13:06 =C0=A0: Alvaro Herrera; 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 ? On 12/05/2014 01:59 PM, Alvaro Herrera wrote: > Now that I think about this, maybe the cache in your case is not being=20 > useful 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?) Ah, good point. psqlodbc does create SAVEPOINTs automatically, if you run i= n the "statement" "rollback on error" mode. That is, Protocol=3D*-2 mode. I= t is the default. You could try setting Protocol=3D7.4-0 in the config file (or set the corre= sponding option in the ODBC configuration GUI) and see if it helps.=20 That changes the behaviour on errors, so that when an error happens the who= le transaction is rolled back, rather than just the statement. I don't know= if that's acceptable for your application, but if it is, you should change= that setting, because that gets rid of the extra SAVEPOINT commands, and i= mproves performance. Even if it turns out not to be the cause of the expone= ntial slowdown. - Heikki --=20 Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-odbc