Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

excessive sorting of expressions [CORE5814] #6076

Open
firebird-automations opened this issue May 4, 2018 · 1 comment
Open

excessive sorting of expressions [CORE5814] #6076

firebird-automations opened this issue May 4, 2018 · 1 comment

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @ibaseru

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.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Dmitry Yemanov [ dimitr ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants