Exclude null values from image studio id index (#5335)

This commit is contained in:
WithoutPants 2024-10-03 11:53:29 +10:00 committed by GitHub
parent c92de09ece
commit 9b567fa6f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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;