Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XkvOC-0005lG-Il for pgsql-jdbc@arkaria.postgresql.org; Sun, 02 Nov 2014 13:40:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XkvOC-00027J-32 for pgsql-jdbc@arkaria.postgresql.org; Sun, 02 Nov 2014 13:40:16 +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 1XkvOA-00026i-WB; Sun, 02 Nov 2014 13:40:15 +0000 Received: from mail-am1on0647.outbound.protection.outlook.com ([2a01:111:f400:fe00::647] helo=emea01-am1-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XkvNx-0007Ar-Vg; Sun, 02 Nov 2014 13:40:12 +0000 Received: from AM2PR07MB0659.eurprd07.prod.outlook.com (25.160.55.150) by AM2PR07MB0658.eurprd07.prod.outlook.com (25.160.55.15) with Microsoft SMTP Server (TLS) id 15.1.11.14; Sun, 2 Nov 2014 13:27:14 +0000 Received: from AM2PR07MB0659.eurprd07.prod.outlook.com ([25.160.55.150]) by AM2PR07MB0659.eurprd07.prod.outlook.com ([25.160.55.150]) with mapi id 15.01.0011.000; Sun, 2 Nov 2014 13:27:14 +0000 From: Mikko Tiihonen To: Andres Freund CC: "pgsql-hackers@postgresql.org" , "pgsql-jdbc@postgresql.org" Subject: Re: [HACKERS] Pipelining executions to postgresql server Thread-Topic: [HACKERS] Pipelining executions to postgresql server Thread-Index: AQHP9doTvFE5xFKaR0KPR7jlrL4JypxMB5MAgAEyENiAAAo8AIAAAUG7 Date: Sun, 2 Nov 2014 13:27:14 +0000 Message-ID: <1414934833900.88748@nitorcreations.com> References: <1414850643686.34687@nitorcreations.com> <20141101173116.GR13584@awork2.anarazel.de> <1414930308808.49160@nitorcreations.com>, <20141102122320.GB28295@alap3.anarazel.de> In-Reply-To: <20141102122320.GB28295@alap3.anarazel.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [89.27.31.97] x-microsoft-antispam: BCL:0;PCL:0;RULEID:;SRVR:AM2PR07MB0658; x-exchange-antispam-report-test: UriScan:; x-forefront-prvs: 03838E948C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(51704005)(377424004)(24454002)(199003)(99396003)(40100003)(551934003)(101416001)(46102003)(15202345003)(122556002)(54356999)(31966008)(50986999)(76176999)(107046002)(4396001)(21056001)(120916001)(105586002)(106356001)(106116001)(95666004)(15975445006)(93886004)(77096003)(77156002)(87936001)(117636001)(2656002)(92566001)(92726001)(110136001)(66066001)(20776003)(19580405001)(64706001)(19580395003)(86362001)(36756003)(97736003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM2PR07MB0658; H:AM2PR07MB0659.eurprd07.prod.outlook.com; FPR:; MLV:sfv; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nitorcreations.com X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org > > > From: Andres Freund > > > On 2014-11-01 14:04:05 +0000, Mikko Tiihonen wrote: > > > > I created a proof of concecpt patch for postgresql JDBC driver that > > > > allows the caller to do pipelining of requests within a > > > > transaction. The pipelining here means same as for HTTP: the client > > > > can send the next execution already before waiting for the response= of > > > > the previous request to be fully processed. > > > > > > Slightly confused here. To my knowledge the jdbc driver already emplo= ys > > > some pipelining? There's some conditions where it's disabled (IIRC > > > RETURNING for DML is one of them), but otherwise it's available. > > > > > > I'm very far from a pgjdbc expert, but that's what I gathered from the > > > code when investigating issues a while back and from my colleague Cra= ig. > > > > Most DB interfaces make the server operations look synchronous. >=20 > You IIRC can use jdbc's batch interface. Yes, there is a limited batch interface for inserts and updates. But for ex= ample when using prepared statements you can only do batches of same statem= ent (with different parameters of course). > > I should have searched earlier a better reference to libpg. I am planni= ng on adding support for something similar to > > http://www.postgresql.org/docs/9.3/static/libpq-async.html > > More specifically operations like: > > int PQsendQuery(PGconn *conn, const char *command); > > PGresult *PQgetResult(PGconn *conn); >=20 > The network protocol allows for pipelining, yes. But libpq unfortunately > doesn't. > You should read the protocol definition. I have studied the protocol, that is why I concluded that it would be possi= ble to add support for pipelining for clients. =20 > > It should be, if the server startd to process (read in) the next query > > only after it has sent the previous response out. >=20 > There's complexities around error handling and such making it slightly > more complex. Are you referring to some complexities on the server side related to error = handling or on the client side? Is the following summary correct: - the network protocol supports pipelinings - the server handles operations in order, starting the processing of next o= peration only after fully processing the previous one - thus pipelining is = invisible to the server - libpq driver does not support pipelining, but that is due to internal lim= itations - if proper error handling is done by the client then there is no reason wh= y pipelining could be supported by any pg client -Mikko --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc