Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 52908 invoked from network); 6 Mar 2008 17:56:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Mar 2008 17:56:14 -0000 Received: (qmail 86141 invoked by uid 500); 6 Mar 2008 17:56:09 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 86110 invoked by uid 500); 6 Mar 2008 17:56:09 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 86101 invoked by uid 99); 6 Mar 2008 17:56:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Mar 2008 09:56:09 -0800 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; Thu, 06 Mar 2008 17:55:42 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 73934234C09C for ; Thu, 6 Mar 2008 09:54:58 -0800 (PST) Message-ID: <2146597426.1204826098472.JavaMail.jira@brutus> Date: Thu, 6 Mar 2008 09:54:58 -0800 (PST) From: "Thomas Nielsen (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Created: (DERBY-3505) Current implementation of ROW_NUMBER() window function does not stop execution once criteria is met MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Current implementation of ROW_NUMBER() window function does not stop execution once criteria is met --------------------------------------------------------------------------------------------------- Key: DERBY-3505 URL: https://issues.apache.org/jira/browse/DERBY-3505 Project: Derby Issue Type: Improvement Components: SQL Affects Versions: 10.4.0.0 Reporter: Thomas Nielsen Using ROW_NUMBER() to limit the number of rows returned is typically done with the following query: SELECT * FROM ( SELECT row_number() over () as r, t.* FROM T ) AS tmp WHERE r <= 3; The query plan shows that the restriction is perfomed in the outermost ProjectRestrictResultSet, and that it actually sees all rows in the table. ******* Project-Restrict ResultSet (1): Number of opens = 1 Rows seen = 1280 Rows filtered = 1277 restriction = true In this case all 1280 rows are read from disk, and passed up the ResultSet chain. 1277 rows are filtered out so that, in the end, we only return 3 rows. Ideally the execution should stop after pulling only 3 rows through the chain. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.