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

Insert ORDER BY column in SELECT to support SELECT * ORDER BY scatter gather #6032

Closed
PrismaPhonic opened this issue Apr 8, 2020 · 6 comments

Comments

@PrismaPhonic
Copy link
Contributor

Feature Description

This feature would rewrite SELECT * ORDER BY queries to include the column in the ORDER BY to be part of the SELECT. This would allow us to instantly support SELECT * ORDER BY scatter gather queries without having to resort to the authoritative vschema feature.

Example

SELECT * FROM popsicle WHERE flavor LIKE '%vanilla%' ORDER BY id would get translated to ->
SELECT id, * FROM popsicle WHERE flavor LIKE '%vanilla%' ORDER BY id

@PrismaPhonic
Copy link
Contributor Author

@systay tagging you for visibility.

@PrismaPhonic
Copy link
Contributor Author

Just as a follow up, the Active Record ORM will often product SELECT <column names> FROM <table name> ORDER BY <different column names>. This feature request could fix this use case as well.

@derekperkins
Copy link
Member

Would you strip the added column before sending it back to the client?

@PrismaPhonic
Copy link
Contributor Author

PrismaPhonic commented Apr 9, 2020

Correct @derekperkins. This would be totally unknown by the client, and is one solution for having immediate support for scatter gather ORDER BY where the column in the ORDER BY isn't in the SELECT. In fact the query translation example listed above is not valid SQL, but actually is understood by vtgate and will result in successful query completion.

@systay systay self-assigned this Jun 8, 2020
@inolddays
Copy link
Contributor

hi there ! wondering if this feature is already existing in 8.0 rc1 ?

@GuptaManan100
Copy link
Member

Support for this has been added in Gen4 in this PR #8070

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

6 participants