You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a simple table "articles" with the fields "id" and "stamp_create". It is "schemaless".
I run a SQL query on the field "stamp_create" and want to see all "ids" of the last 5 days.
select id,stamp_create FROM articles WHERE stamp_create > (time::now() - 5d) LIMIT 5;
Without using the index on the "datetime" field in combination with the "time::*()" functions, it is very slow when querying large records (250K in this case). We are in the high second range here, not the millisecond range.
If you add sorting with "ORDER BY", where no index is currently used (see #2799 or #3746), the performance looks very bad. Time calculations and time limits in particular are very important for a large DB.
P.S. The documentation could include more examples of Datetime calculations using functions, such as adding or subtracting times, etc. Under "Datetime comparison" there is only a simple example without the use of functions.
SurrealDB version
Running 1.4.2 for linux on x86_64 (Ubuntu)
The text was updated successfully, but these errors were encountered:
Thanks for reporting this. Indeed, the query planner does not trigger the index due to the complex operand (time::now() - 5d). We are going to open a PR soon to fix this.
I have a simple table "articles" with the fields "id" and "stamp_create". It is "schemaless".
I run a SQL query on the field "stamp_create" and want to see all "ids" of the last 5 days.
select id,stamp_create FROM articles WHERE stamp_create > (time::now() - 5d) LIMIT 5;
This also works in the end result:
-- Query 1 (execution time: 1.233700179s)
I have an index on the column "stamp_create":
However, this index is not used in the SQL query:
A appears instead:
Unsupported value: time::now()
Without using the index on the "datetime" field in combination with the "time::*()" functions, it is very slow when querying large records (250K in this case). We are in the high second range here, not the millisecond range.
If you add sorting with "ORDER BY", where no index is currently used (see #2799 or #3746), the performance looks very bad. Time calculations and time limits in particular are very important for a large DB.
P.S. The documentation could include more examples of Datetime calculations using functions, such as adding or subtracting times, etc. Under "Datetime comparison" there is only a simple example without the use of functions.
SurrealDB version
Running 1.4.2 for linux on x86_64 (Ubuntu)
The text was updated successfully, but these errors were encountered: