-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add index for db_directory_id column in SQLite (#1511)
Noticed that deleting objects takes forever on Arequipa. Turns out we were missing an index. Also snuck in a little change here to prevent account refill spam for accounts that don't need to be refreshed. Before adding missing index ``` sqlite> DELETE FROM directories WHERE directories.id != 1 AND NOT EXISTS (SELECT 1 FROM objects WHERE objects.db_directory_id = directories.id) AND NOT EXISTS (SELECT 1 FROM (SELECT 1 FROM directories AS d WHERE d.db_parent_id = directories.id)i); Run Time: real 61.209 user 35.705172 sys 25.502178 ``` After adding missing index ``` sqlite> DELETE FROM directories WHERE directories.id != 1 AND NOT EXISTS (SELECT 1 FROM objects WHERE objects.db_directory_id = directories.id) AND NOT EXISTS (SELECT 1 FROM (SELECT 1 FROM directories AS d WHERE d.db_parent_id = directories.id)i); Run Time: real 0.020 user 0.018806 sys 0.001690 ```
- Loading branch information
Showing
5 changed files
with
18 additions
and
9 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
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
1 change: 1 addition & 0 deletions
1
stores/sql/mysql/migrations/main/migration_00020_idx_db_directory.sql
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 @@ | ||
|
1 change: 1 addition & 0 deletions
1
stores/sql/sqlite/migrations/main/migration_00020_idx_db_directory.sql
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 @@ | ||
CREATE INDEX IF NOT EXISTS `idx_objects_db_directory_id` ON `objects`(`db_directory_id`); |
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