Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 51456 invoked from network); 19 Apr 2010 18:52:13 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 19 Apr 2010 18:52:13 -0000 Received: (qmail 90123 invoked by uid 500); 19 Apr 2010 18:52:12 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 89356 invoked by uid 500); 19 Apr 2010 18:52:11 -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 89349 invoked by uid 99); 19 Apr 2010 18:52:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Apr 2010 18:52:11 +0000 X-ASF-Spam-Status: No, hits=-1312.4 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Apr 2010 18:52:10 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o3JIpoiq003711 for ; Mon, 19 Apr 2010 14:51:50 -0400 (EDT) Message-ID: <19168832.18111271703110112.JavaMail.jira@thor> Date: Mon, 19 Apr 2010 14:51:50 -0400 (EDT) From: "Knut Anders Hatlen (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-4406) Wrong order when using ORDER BY on non-deterministic function In-Reply-To: <1093343113.1255361491709.JavaMail.jira@brutus> 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-4406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12858631#action_12858631 ] Knut Anders Hatlen commented on DERBY-4406: ------------------------------------------- Hi Lily, If you have two equivalent queries that only differ in whether they use correlation names, the performance should be identical. I think the compiler also adds auto-generated correlation names internally if there is no explicit correlation name given, so there should be no difference at execution time. > Wrong order when using ORDER BY on non-deterministic function > ------------------------------------------------------------- > > Key: DERBY-4406 > URL: https://issues.apache.org/jira/browse/DERBY-4406 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.5.3.0, 10.6.0.0 > Reporter: Knut Anders Hatlen > Assignee: C.S. Nirmal J. Fernando > > If I read the SQL standard correctly, a statement such as "select random() as r from t order by random()" should be treated as "select random() as r from t order by r". Derby does however generate a second, hidden random() column by which the rows are ordered. > ij> create table t(x int); > 0 rows inserted/updated/deleted > ij> insert into t values 1,2,3,4,5; > 5 rows inserted/updated/deleted > ij> -- wrong result, not ordered by r > ij> select random() as r from t order by random(); > R > ---------------------- > 0.1285512465366495 > 0.5116860880915798 > 0.21060042130229073 > 0.2506706923680875 > 0.6378857329935494 > 5 rows selected > ij> -- correct result, ordered by r > ij> select random() as r from t order by r; > R > ---------------------- > 0.0749025910679918 > 0.07694931688380491 > 0.1724114605785414 > 0.2268758969382877 > 0.31900450349277965 > 5 rows selected -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.