Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E6302D69C for ; Mon, 1 Oct 2012 17:11:07 +0000 (UTC) Received: (qmail 98282 invoked by uid 500); 1 Oct 2012 17:11:07 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 98253 invoked by uid 500); 1 Oct 2012 17:11:07 -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 98245 invoked by uid 99); 1 Oct 2012 17:11:07 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Oct 2012 17:11:07 +0000 Date: Tue, 2 Oct 2012 04:11:07 +1100 (NCT) From: "Mamta A. Satoor (JIRA)" To: derby-dev@db.apache.org Message-ID: <1576455047.148616.1349111467745.JavaMail.jiratomcat@arcas> Subject: [jira] [Updated] (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-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-3505?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Mamta A. Satoor updated DERBY-3505: ----------------------------------- Urgency: Normal Labels: derby_triage10_10 (was: ) > 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.1.3 > Reporter: Thomas Nielsen > Labels: derby_triage10_10 > > 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. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira