Skip to content

Commit

Permalink
Exclude null values from image studio id index
Browse files Browse the repository at this point in the history
  • Loading branch information
WithoutPants committed Oct 3, 2024
1 parent 9765b6d commit fc1fe05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/sqlite/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
cacheSizeEnv = "STASH_SQLITE_CACHE_SIZE"
)

var appSchemaVersion uint = 67
var appSchemaVersion uint = 68

//go:embed migrations/*.sql
var migrationsBox embed.FS
Expand Down
7 changes: 7 additions & 0 deletions pkg/sqlite/migrations/68_image_studio_index.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- with the existing index, if no images have a studio id, then the index is
-- not used when filtering by studio id. The assumption with this change is that
-- most images don't have a studio id, so filtering by non-null studio id should
-- be faster with this index. This is a tradeoff, as filtering by null studio id
-- will be slower.
DROP INDEX index_images_on_studio_id;
CREATE INDEX `index_images_on_studio_id` on `images` (`studio_id`) WHERE `studio_id` IS NOT NULL;

0 comments on commit fc1fe05

Please sign in to comment.