Issue Details (XML | Word | Printable)

Key: CORE-5814
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Dmitry Yemanov
Reporter: kdv
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Firebird Core

excessive sorting of expressions

Created: 04/May/18 03:44 PM   Updated: 04/May/18 04:21 PM
Component/s: Engine
Affects Version/s: 2.5.7, 3.0.3
Fix Version/s: None

QA Status: No test


 Description  « Hide
Grouping and sorting on expression produces additional SORT in plan.
Example.

When we group and sort on non-indexed field

select first_name, max(first_name)
from employee
group by 1
order by 1

we see PLAN SORT (EMPLOYEE NATURAL)
i.e only one sort used for grouping and sorting.
But, if we convert field to expression

select first_name||'', max(first_name)
from employee
group by 1
order by 1

plan will have 2 sorts - for group by and order by
PLAN SORT (SORT (EMPLOYEE NATURAL))

I don't know is this a real bug or engine specific, but maybe it can be fixed.

In addition. If I create computed index
create index bfc on employee computed by (first_name||'')

plan for the last query will be
PLAN SORT (EMPLOYEE ORDER BFC)

So, index is used by group by, but order by still uses additional sorting.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.