Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XoZkb-00005i-KO for pgsql-jdbc@arkaria.postgresql.org; Wed, 12 Nov 2014 15:22:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XoZka-0005km-Is for pgsql-jdbc@arkaria.postgresql.org; Wed, 12 Nov 2014 15:22:28 +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 1XoZkT-0005Yi-Qf for pgsql-jdbc@postgresql.org; Wed, 12 Nov 2014 15:22:22 +0000 Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XoZkN-0001av-Lr for pgsql-jdbc@postgresql.org; Wed, 12 Nov 2014 15:22:17 +0000 Received: by mail-wi0-f169.google.com with SMTP id n3so5270760wiv.0 for ; Wed, 12 Nov 2014 07:22:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:message-id:date :to:mime-version; bh=fo6qDPB7jfT5Tn/GxZetYFI62p0RntjOqaCJD4WkrHg=; b=AWBpZ0TupsDVCtUZBpiB8UC0QEji2RVJlc4lycGIuZ5xpkgJGIlAaoSVoxaXj0GOS0 O6sfgyaMvBUxjxDsPhIU1FdIGNIgTWlzjik9nX9lkijlm3Yod48/ZhYKyiiBUTtZoW+R bBFi/MZuZGLEPjPyCjJiKfjlTuJz5bF6X1j0M4FPR0QcG3zic82WZo+uzJO+L2epvX6S fvEMIxPIyK0VBJMzHXfs+VF6pfA6Nt6XYm4BcaUEMMhzUAtEvCncboRYdD5KBo6SfKsE Q+ANJK4POE85uU4/hW7f9b+m/dZXfHxwNM7SAJyMPei1lk+/z2PHvaI8lM9Ofr+UVJ0v hatg== X-Received: by 10.194.48.116 with SMTP id k20mr66037637wjn.7.1415805733931; Wed, 12 Nov 2014 07:22:13 -0800 (PST) Received: from [192.168.18.150] ([31.45.243.121]) by mx.google.com with ESMTPSA id bc1sm22008614wib.16.2014.11.12.07.22.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Nov 2014 07:22:13 -0800 (PST) From: Marko Topolnik Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: New significance of holdable result sets in Java 8 Message-Id: <771672CB-9567-4966-8CE9-9D84E4F858D8@gmail.com> Date: Wed, 12 Nov 2014 16:22:18 +0100 To: pgsql-jdbc@postgresql.org Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) X-Mailer: Apple Mail (2.1878.6) X-Pg-Spam-Score: -2.7 (--) 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 As of the release of Java 8 and its Streams API a new door has opened for m= any things, including an important improvement in the way RESTful services = can be implemented. Let me briefly describe the architecture with Spring's = REST support: an MVC framework is used where the Controller dispatches the = HTTP request to a Service method; the Service method contacts the database = and returns a Model-oriented representation of the response; the View layer= then transforms it into the actual HTTP response bytes. Data is passed from Controller to View as the return value of a method. Tra= ditionally, if you wanted a collection-shaped response, you would return a = List. This meant eager loading of all data needed for the response, which c= aused scalability issues related to the JVM heap space. With the Streams API it is now very convenient to return a lazily-evaluated= stream of Model objects. It is also very convenient to make this stream pu= ll data directly from an underlying ResultSet, tronsforming each row on-the= -fly into a Model object. This, however, calls for holdable result sets bec= ause the transaction commits when program control leaves the Service layer. The Spring team has recognized the relevance of the above use case and with= release 4.1.2 they have introduced a specific enhancement needed to suppor= t result sets holdable into the View layer (albeit only when JDBC is used o= ver Hibernate). This is described in the issue SPR-12349 [1]. Spring also p= lans to support this use case with additional helper code which turns Hiber= nate's ScrollableResults into a Stream (SPR-12388 [2]). The above could raise the level of interest of the PostgreSQL JDBC team in = implementing holdable result sets backed by native holdable cursors instead= of the current client-side cursors, which don't allow the space complexity= to be reduced from O(n) to O(1) on the JVM side. I am aware that this is n= ot a trivial endeavor as it requires intervention into the FE/BE protocol, = but I would nevertheless propose that this concern be reassessed in the lig= ht of new developments in the Java ecosystem. Regards, Marko Topolnik [1] https://jira.spring.io/browse/SPR-12349 [2] https://jira.spring.io/browse/SPR-12388 --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc