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

Feature: Use index For Order By and allow to define index order and Null First or last #2799

Open
2 tasks done
damianbenente opened this issue Oct 5, 2023 · 0 comments
Open
2 tasks done
Labels
feature New feature or request topic:indexing This is related to indexing and full-text search

Comments

@damianbenente
Copy link

Is your feature request related to a problem?

It would be nice to have something like postgres for the index creation also Like
CREATE INDEX test2_info_nulls_low ON test2 (info NULLS FIRST);
CREATE INDEX test3_desc_index ON test3 (id DESC NULLS LAST);

Describe the solution

.

Alternative methods

Currently the only way I can find to order by index is do a query with a WHERE instruction that I know that will match everything
For example I have a table with a indexed field to order if I want to use it for sorting will only work fast for ASC
sortingField = [1, 2, 3, 4 .... etc ]

SELECT * FROM Table WHERE sortingField > 0 limit 10; Return 10 records in ascending order from sortingField very fast
if I use ORDER BY sortingField DESC is very slow

Only way I found to do a Desc Search is to copy the sortingField and negate it (negate_sortingField = [-1, -2, -3, -4 .... etc ]
SELECT * FROM Table WHERE negate_sortingField < 0 limit 10; Return 10 records in descending order from negate_sortingField very fast

SurrealDB version

1.0.0+20230913.54aedcd for linux on x86_64

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@damianbenente damianbenente added feature New feature or request triage This issue is new labels Oct 5, 2023
@AlexFrid AlexFrid removed the triage This issue is new label Jan 11, 2024
@kearfy kearfy added the topic:indexing This is related to indexing and full-text search label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request topic:indexing This is related to indexing and full-text search
Projects
None yet
Development

No branches or pull requests

3 participants