Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XlIbp-00025e-VI for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Nov 2014 14:27:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XlIbp-0003H8-F2 for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Nov 2014 14:27:53 +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 1XlIbo-0003Gx-CQ; Mon, 03 Nov 2014 14:27:52 +0000 Received: from mout.kundenserver.de ([212.227.126.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XlIbg-0007j8-Is; Mon, 03 Nov 2014 14:27:50 +0000 Received: from ayaki.localdomain (58-7-68-63.dyn.iinet.net.au [58.7.68.63]) by mrelayeu.kundenserver.de (node=mreue002) with ESMTP (Nemesis) id 0LvN23-1YAqBL0rP1-010YrM; Mon, 03 Nov 2014 15:27:42 +0100 Message-ID: <545790D8.9090201@2ndquadrant.com> Date: Mon, 03 Nov 2014 22:27:36 +0800 From: Craig Ringer Organization: 2nd Quadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 MIME-Version: 1.0 To: Mikko Tiihonen , Andres Freund CC: "pgsql-hackers@postgresql.org" , "pgsql-jdbc@postgresql.org" Subject: Re: Pipelining executions to postgresql server References: <1414850643686.34687@nitorcreations.com> <20141101173116.GR13584@awork2.anarazel.de> <1414930308808.49160@nitorcreations.com>, <20141102122320.GB28295@alap3.anarazel.de> <1414934833900.88748@nitorcreations.com> In-Reply-To: <1414934833900.88748@nitorcreations.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:ErJfku85e7h5Hk9oc2W9cykY/9+PB8Z3u1M8GCumI1E dspijm1EO9Y6N/qndW/nmUA6NSFloDSg5zduUE+BxcgShnbsnj t+IFaC0IYWM209NmpNt96Ib6f6cz3P9+mxlL3LBZTshErUgnR5 fPqsSQAY753t5KS34M5/GKr6TF1mbQol2Pru5QlpRFKMhn2l4Z VcVhP0lvUU63rAMbPGlIWZrr+b6jqyvKth7PBfwzfU0B7MMuMC eRtIUT2j7/MDNPjZLLKMqctTeDHEgGDntmVcL0YaCUaUehnRSD 4GzdxQD8RpafPLH3cUPV3JiuacWiLThYLihGOtyqWuCjD9loCS nNV3/A/ag9YzMUc1CNs3PijLUmhuYvXmutVzGJqRT X-UI-Out-Filterresults: notjunk:1; X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 11/02/2014 09:27 PM, Mikko Tiihonen wrote: > Is the following summary correct: > - the network protocol supports pipelinings Yes. All you have to do is *not* send a Sync message and be aware that the server will discard all input until the next Sync, so pipelining + autocommit doesn't make a ton of sense for error handling reasons. > - the server handles operations in order, starting the processing of next operation only after fully processing the previous one - thus pipelining is invisible to the server As far as I know, yes. The server just doesn't care. > - libpq driver does not support pipelining, but that is due to internal limitations Yep. > - if proper error handling is done by the client then there is no reason why pipelining could be supported by any pg client Indeed, and most should support it. Sending batches of related queries would make things a LOT faster. PgJDBC's batch support is currently write-oriented. There is no fundamental reason it can't be expanded for reads. I've already written a patch to do just that for the case of returning generated keys. https://github.com/ringerc/pgjdbc/tree/batch-returning-support and just need to rebase it so I can send a pull for upstream PgJDBC. It's already linked in the issues documenting the limitatations in batch support. If you want to have more general support for batches that return rowsets there's no fundamental technical reason why it can't be added. It just requires some tedious refactoring of the driver to either: - Sync and wait before it fills its *send* buffer, rather than trying to manage its receive buffer (the server send buffer), so it can reliably avoid deadlocks; or - Do async I/O in a select()-like loop over a protocol state machine, so it can simultaneously read and write on the wire. I might need to do some of that myself soon, but it's a big (and therefore error-prone) job I've so far avoided by making smaller, more targeted changes. Doing async I/O using Java nio channels is by far the better approach, but also the more invasive one. The driver currently sends data on the wire where it generates it and blocks to receive expected data. Switching to send-side buffer management doesn't have the full performance gains that doing bidirectional I/O via channels does, though, and may be a significant performance _loss_ if you're sending big queries but getting small replies. For JDBC the JDBC batch interface is the right place to do this, and you should not IMO attempt to add pipelining outside that interface. (Multiple open resultsets from portals, yes, but not pipelining of queries). -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers