Where possible, transform the DISTINCT qualifier to a GROUP BY clause. GROUP BY clauses may be optimized by indices, DISTINCT qualifiers cannot. (CVS 4538)
FossilOrigin-Name: e56331234791cf3d830a30e4cfa66682bdf2eed1
This commit is contained in:
+4
-4
@@ -14,7 +14,7 @@
|
||||
# SELECT statements that use user-defined collation sequences. Also
|
||||
# GROUP BY clauses that use user-defined collation sequences.
|
||||
#
|
||||
# $Id: collate5.test,v 1.5 2005/09/07 22:48:16 drh Exp $
|
||||
# $Id: collate5.test,v 1.6 2007/11/12 15:29:19 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -57,17 +57,17 @@ do_test collate5-1.1 {
|
||||
execsql {
|
||||
SELECT DISTINCT a FROM collate5t1;
|
||||
}
|
||||
} {a b n}
|
||||
} {A B N}
|
||||
do_test collate5-1.2 {
|
||||
execsql {
|
||||
SELECT DISTINCT b FROM collate5t1;
|
||||
}
|
||||
} {apple Apple banana {}}
|
||||
} {{} Apple apple banana}
|
||||
do_test collate5-1.3 {
|
||||
execsql {
|
||||
SELECT DISTINCT a, b FROM collate5t1;
|
||||
}
|
||||
} {a apple A Apple b banana n {}}
|
||||
} {A Apple a apple B banana N {}}
|
||||
|
||||
# The remainder of this file tests compound SELECT statements.
|
||||
# Omit it if the library is compiled such that they are omitted.
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the INSERT transfer optimization.
|
||||
#
|
||||
# $Id: insert4.test,v 1.8 2007/10/09 08:29:32 danielk1977 Exp $
|
||||
# $Id: insert4.test,v 1.9 2007/11/12 15:29:19 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -112,7 +112,7 @@ do_test insert4-2.4.1 {
|
||||
INSERT INTO t3 SELECT DISTINCT * FROM t2;
|
||||
SELECT * FROM t3;
|
||||
}
|
||||
} {9 1 1 9}
|
||||
} {1 9 9 1}
|
||||
xferopt_test insert4-2.4.2 0
|
||||
do_test insert4-2.4.3 {
|
||||
catchsql {
|
||||
|
||||
+12
-2
@@ -13,7 +13,7 @@
|
||||
# This file implements tests for miscellanous features that were
|
||||
# left out of other test files.
|
||||
#
|
||||
# $Id: misc5.test,v 1.17 2007/09/12 17:01:45 danielk1977 Exp $
|
||||
# $Id: misc5.test,v 1.18 2007/11/12 15:29:19 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -481,8 +481,18 @@ ifcapable subquery {
|
||||
SELECT songid
|
||||
FROM songs
|
||||
WHERE LOWER(artist) = (
|
||||
-- This sub-query is indeterminate. Because there is no ORDER BY,
|
||||
-- it may return 'one', 'two' or 'three'. Because of this, the
|
||||
-- outermost parent query may correctly return any of 'one', 'two'
|
||||
-- or 'three' as well.
|
||||
SELECT DISTINCT LOWER(artist)
|
||||
FROM (
|
||||
-- This sub-query returns the table:
|
||||
--
|
||||
-- two 14
|
||||
-- one 10
|
||||
-- three 5
|
||||
--
|
||||
SELECT DISTINCT artist,sum(timesplayed) AS total
|
||||
FROM songs
|
||||
GROUP BY LOWER(artist)
|
||||
@@ -495,7 +505,7 @@ ifcapable subquery {
|
||||
)
|
||||
ORDER BY LOWER(artist) ASC;
|
||||
}
|
||||
} {two}
|
||||
} {one}
|
||||
}
|
||||
|
||||
# Ticket #1370. Do not overwrite small files (less than 1024 bytes)
|
||||
|
||||
Reference in New Issue
Block a user