mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-25 20:14:21 +01:00
Made a new PR based on @sivukhin 's PR #2869 that had a lot of conflicts. You can check out the PR description from there. ## The main idea is: Before, if we had an index on `x` and had a query like `WHERE x > 100 and x < 200`, the plan would be something like: ``` - Seek to first row where x > 100 - Then, for every row, discard the row if x >= 200 ``` This is highly wasteful in cases where there are a lot of rows where `x >= 200`. Since our index is sorted on `x`, we know that once we hit the _first_ row where `x >= 200`, we can stop iterating entirely. So, the new plan is: ``` - Seek to first row where x > 100 - Then, iterate rows until x >= 200, and then stop ``` This also improves the situation for multi-column indexes. Imagine index on `(x,y)` and a condition like `WHERE x = 100 and y > 100 and y < 200`. Before, the plan was: ``` - Seek to first row where x=100 and y > 100 - Then, iterate rows while x = 100 and discard the row if y >= 200 - Stop when x > 100 ``` This also suffers from a problem where if there are a lot of rows where `x=100` and `y >= 200`, we go through those rows unnecessarily. The new plan is: ``` - Seek to first row where x=100 and y > 100 - Then, iterate rows while x = 100 and y < 200 - Stop when either x > 100 or y >= 200 ``` Which prevents us from iterating rows like `x=100, y = 666` unnecessarily because we know the index is sorted on `(x,y)` - once we hit any row where `x>100` OR `x=100, y >= 200`, we can stop. Closes #3644
Turso Testing
Testing Extensions
When adding tests for extensions, please follow these guidelines:
- Tests that verify the internal logic or behavior of a particular extension should go into
cli_tests/extensions.py. - Tests that verify how extensions interact with the database engine, such as virtual table handling, should be written
in TCL (see
vtab.testas an example).
To check which extensions are available in TCL, or to add a new one, refer to the tester.tcl file and look at the extension_map.