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

sql: ordering of SRFs is not taken into account during planning #26704

Open
knz opened this issue Jun 13, 2018 · 3 comments
Open

sql: ordering of SRFs is not taken into account during planning #26704

knz opened this issue Jun 13, 2018 · 3 comments
Labels
A-sql-optimizer SQL logical planning and optimizations. C-performance Perf of queries or internals. Solution not expected to change functional behavior. T-sql-queries SQL Queries Team X-nostale Marks an issue/pr that should be ignored by the stale bot
Projects

Comments

@knz
Copy link
Contributor

knz commented Jun 13, 2018

If a result order is required on the output of a SRF, a sort stage will always be added, even though most SRFs have a natural order (generate_series in the direction of the increment, generate_subscripts is always ascending, _pg_expandarray is always ascending in the subscript column, etc).

This would benefit from a simplification based on some properties annotated on the SRFs themselves.

Found while investigating #26701.

cc @RaduBerinde @solongordon

Jira issue: CRDB-4990

@knz knz added C-performance Perf of queries or internals. Solution not expected to change functional behavior. A-sql-optimizer SQL logical planning and optimizations. labels Jun 13, 2018
@andy-kimball andy-kimball added this to Higher Priority Backlog in BACKLOG, NO NEW ISSUES: SQL Optimizer Aug 25, 2018
@RaduBerinde RaduBerinde moved this from Higher Priority Backlog to Plan enhancements (lower priority) in BACKLOG, NO NEW ISSUES: SQL Optimizer Apr 18, 2020
@github-actions
Copy link

github-actions bot commented Jun 6, 2021

We have marked this issue as stale because it has been inactive for
18 months. If this issue is still relevant, removing the stale label
or adding a comment will keep it active. Otherwise, we'll close it in
5 days to keep the issue queue tidy. Thank you for your contribution
to CockroachDB!

@knz knz added this to Triage in SQL Queries via automation Jun 7, 2021
@rytaft rytaft moved this from Triage to Backlog in SQL Queries Jun 8, 2021
@RaduBerinde RaduBerinde removed this from Plan enhancements (lower priority) in BACKLOG, NO NEW ISSUES: SQL Optimizer Jun 8, 2021
@jlinder jlinder added the T-sql-queries SQL Queries Team label Jun 16, 2021
@rytaft rytaft moved this from Backlog to 21.2 High Likelihood (90%) in SQL Queries Jul 1, 2021
@rytaft
Copy link
Collaborator

rytaft commented Aug 30, 2021

This issue does not seem urgent, so I'm moving it out of the High Likelihood bucket for this release. Feel free to comment if you disagree.

@rytaft rytaft moved this from 21.2 High Likelihood (90%) to 21.2 Low Likelihood (10%) in SQL Queries Aug 30, 2021
@rytaft rytaft moved this from 22.1 Low Likelihood (10%) to 22.1 High Likelihood (90%) in SQL Queries Aug 30, 2021
michae2 added a commit to michae2/cockroach that referenced this issue Jan 29, 2022
Addresses: cockroachdb#26704

ProjectSet, like Project, should always preserve input orderings (for columns
that are included in the output). Previously we were not tracking this in the
optimizer. This patch adds ordering code for ProjectSet (which mostly matches
the ordering code for Project).

This patch does not add orderings that come from the zipped functions, such as
set-returning functions like `generate_series`, so this does not yet fix

Release note: None
@michae2 michae2 moved this from 22.1 High Likelihood (90%) to 22.2 Medium Likelihood (60%) in SQL Queries Apr 11, 2022
@michae2 michae2 moved this from 22.2 Medium Likelihood (60%) to 22.2 Low Likelihood (10%) in SQL Queries Apr 11, 2022
@rytaft rytaft moved this from 22.2 Low Likelihood (10%) to 22.2 Release in SQL Queries May 25, 2022
@mgartner mgartner moved this from 22.2 Release to Backlog in SQL Queries Jul 7, 2022
Copy link

github-actions bot commented Jan 1, 2024

We have marked this issue as stale because it has been inactive for
18 months. If this issue is still relevant, removing the stale label
or adding a comment will keep it active. Otherwise, we'll close it in
10 days to keep the issue queue tidy. Thank you for your contribution
to CockroachDB!

@michae2 michae2 added X-nostale Marks an issue/pr that should be ignored by the stale bot and removed no-issue-activity labels Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-optimizer SQL logical planning and optimizations. C-performance Perf of queries or internals. Solution not expected to change functional behavior. T-sql-queries SQL Queries Team X-nostale Marks an issue/pr that should be ignored by the stale bot
Projects
Status: Backlog
SQL Queries
Backlog (DO NOT ADD NEW ISSUES)
Development

No branches or pull requests

4 participants