Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XkuBt-0003PU-W3 for pgsql-jdbc@arkaria.postgresql.org; Sun, 02 Nov 2014 12:23:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XkuBt-0005M3-EV for pgsql-jdbc@arkaria.postgresql.org; Sun, 02 Nov 2014 12:23:29 +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 1XkuBr-0005Ix-RN; Sun, 02 Nov 2014 12:23:27 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XkuBo-0005oE-8Q; Sun, 02 Nov 2014 12:23:25 +0000 Received: from intern.anarazel.de (p5DDC6BFD.dip0.t-ipconnect.de [93.220.107.253]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 9E516E0969; Sun, 2 Nov 2014 13:23:21 +0100 (CET) Date: Sun, 2 Nov 2014 13:23:20 +0100 From: Andres Freund To: Mikko Tiihonen Cc: "pgsql-hackers@postgresql.org" , "pgsql-jdbc@postgresql.org" Subject: Re: [HACKERS] Pipelining executions to postgresql server Message-ID: <20141102122320.GB28295@alap3.anarazel.de> References: <1414850643686.34687@nitorcreations.com> <20141101173116.GR13584@awork2.anarazel.de> <1414930308808.49160@nitorcreations.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1414930308808.49160@nitorcreations.com> X-Pg-Spam-Score: -2.6 (--) 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 On 2014-11-02 12:11:49 +0000, Mikko Tiihonen wrote: > > 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 employs > > 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 Craig. > > Most DB interfaces make the server operations look synchronous. You IIRC can use jdbc's batch interface. > I should have searched earlier a better reference to libpg. I am planning 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); That doesn't really support pipelining though - you can still only send one query. It's nonblocking, but that's a different thing. > In libpg terms: Is it safe to do multiple PQsendQuery operations > before invoking PQgetResult as many times? The network protocol allows for pipelining, yes. But libpq unfortunately doesn't. You should read the protocol definition. > It should be, if the server startd to process (read in) the next query > only after it has sent the previous response out. There's complexities around error handling and such making it slightly more complex. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc