-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #367 from evoluhq/generateSql
Indexes
- Loading branch information
Showing
33 changed files
with
2,256 additions
and
1,667 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
"@evolu/common": minor | ||
--- | ||
|
||
Indexes (or indices, we don't judge) | ||
|
||
This release brings SQLite indexes support to Evolu with two helpful options for `evolu.createQuery` functions. | ||
|
||
```ts | ||
const indexes = [ | ||
createIndex("indexTodoCreatedAt").on("todo").column("createdAt"), | ||
]; | ||
|
||
const evolu = createEvolu(Database, { | ||
// Try to remove/re-add indexes with `logExplainQueryPlan`. | ||
indexes, | ||
}); | ||
|
||
const allTodos = evolu.createQuery( | ||
(db) => db.selectFrom("todo").orderBy("createdAt").selectAll(), | ||
{ | ||
logExecutionTime: true, | ||
// logExplainQueryPlan: false, | ||
}, | ||
); | ||
``` | ||
|
||
Indexes are not necessary for development but are required for production. | ||
|
||
Before adding an index, use `logExecutionTime` and `logExplainQueryPlan` | ||
createQuery options. | ||
|
||
SQLite has [a tool](https://sqlite.org/cli.html#index_recommendations_sqlite_expert_) for index recommendations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.