Return-Path: Delivered-To: apmail-cayenne-commits-archive@www.apache.org Received: (qmail 96897 invoked from network); 20 May 2009 13:17:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 May 2009 13:17:01 -0000 Received: (qmail 57261 invoked by uid 500); 20 May 2009 13:17:14 -0000 Delivered-To: apmail-cayenne-commits-archive@cayenne.apache.org Received: (qmail 57234 invoked by uid 500); 20 May 2009 13:17:14 -0000 Mailing-List: contact commits-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list commits@cayenne.apache.org Received: (qmail 57224 invoked by uid 99); 20 May 2009 13:17:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 May 2009 13:17:10 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 May 2009 13:17:06 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 89D6B234C004 for ; Wed, 20 May 2009 06:16:45 -0700 (PDT) Message-ID: <842338907.1242825405550.JavaMail.jira@brutus> Date: Wed, 20 May 2009 06:16:45 -0700 (PDT) From: "Stephane Claret (JIRA)" To: commits@cayenne.apache.org Subject: [jira] Issue Comment Edited: (CAY-1225) Controlling JDBC Driver setting "fetchSize" in a SelectQuery In-Reply-To: <293925679.1242553545560.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CAY-1225?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12711131#action_12711131 ] Stephane Claret edited comment on CAY-1225 at 5/20/09 6:15 AM: --------------------------------------------------------------- Modified files: Original come from v3 M6 generic-unpublished version. -People who can't wait for this feature to be publicly available can use this patch. Modified sections are marked with comment "quick fix". -I added cursorFetchSize property in SelectQuery (nullable Integer). If set, it is used to modify the preparedStatement in SelectAction.performAction otherwise it has no effect, there should be no risk to break existing code. The same fix can be applied to current v2 sources (2.04) too, but in that case, if you're using ResultIterator and convert DataRows to DataObjects, you still have to manually unregister them from the DataContext in your iteration loop in order to avoid memory issues. was (Author: stefcl): Modified files: Original come from v3 M6 generic-unpulished version. -People who can't wait for this feature to be publicly available can use this patch. Modified sections are marked with comment "quick fix". -I added cursorFetchSize property in SelectQuery (nullable Integer). If set, it is used to modify the preparedStatement in SelectAction.performAction otherwise it has no effect, there should be no risk to break existing code. > Controlling JDBC Driver setting "fetchSize" in a SelectQuery > ------------------------------------------------------------ > > Key: CAY-1225 > URL: https://issues.apache.org/jira/browse/CAY-1225 > Project: Cayenne > Issue Type: Improvement > Components: Cayenne Core Library > Affects Versions: 2.0 branch > Reporter: Stephane Claret > Priority: Critical > Attachments: SelectAction.java, SelectQuery.java > > > ResultIterator is a nice API for dealing with large SELECT queries, unfortunately some JDBC drivers that don't automatically use server-side cursors (eg PostgreSQL JDBC driver) wont'give access to the ResultSet (at JDBC level) until the whole query has finished executing and all rows have been returned. > It basically mean that if you execute a SelectQuery returning 1'500'000 rows, there's a high chance of getting a OutOfMemoryException in the JDBC driver code (Statement.Excecute), before Cayenne even gets a chance to call the ResultSet.Next(). > > It makes the ResultIterator API much less efficient than it could be because : > -Even if rows are processed one by one, they need to be stored in local memory, causing heap size issues. > -In some scenarios, user code could start working with the resulting rows immediately as they become available, while the select query is still being executed by the database engine. > To solve this problem, there should be a way to have the SelectQuery object calling Statement.setFetchSize() before it executes. > A SelectQuery.setFetchSize( int ) method would be perfect because it's often needed to configure this setting on a per-query basis. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.