Remove unnescesary sorting on fields different then first when do union
-----------------------------------------------------------------------
Key: CORE-5497
URL: http://tracker.firebirdsql.org/browse/CORE-5497
Project: Firebird Core
Issue Type: Improvement
Reporter: Karol Bieniaszewski
For query like this Firebird remove unnescessary sorting but only if we order
by first column
SELECT
R.RDB$RELATION_NAME, R.RDB$DBKEY_LENGTH
FROM
RDB$RELATIONS R
UNION
SELECT
R.RDB$RELATION_NAME, R.RDB$DBKEY_LENGTH
FROM
RDB$RELATIONS R
ORDER BY 1
Select Expression
-> Unique Sort (record length: 150, key length: 108)
-> Union
-> Table "RDB$RELATIONS" as "R" Full Scan
-> Table "RDB$RELATIONS" as "R" Full Scan
but when we change query to and sort on second field (same fields but swapped)
SELECT
R.RDB$DBKEY_LENGTH, R.RDB$RELATION_NAME
FROM
RDB$RELATIONS R
UNION
SELECT
R.RDB$DBKEY_LENGTH, R.RDB$RELATION_NAME
FROM
RDB$RELATIONS R
ORDER BY 2
Select Expression
-> Sort (record length: 142, key length: 100)
-> Unique Sort (record length: 150, key length: 108)
-> Union
-> Table "RDB$RELATIONS" as "R" Full Scan
-> Table "RDB$RELATIONS" as "R" Full Scan
we have 2 sorts - one is unnescessary
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Firebird-Devel mailing list, web interface at
https://lists.sourceforge.net/lists/listinfo/firebird-devel