Add indexes for improved query performance
This commit is contained in:
9
migrations/2025-12-17-230000_add_indexes/down.sql
Normal file
9
migrations/2025-12-17-230000_add_indexes/down.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- Rollback indexes
|
||||
|
||||
DROP INDEX IF EXISTS idx_favorites_userid;
|
||||
DROP INDEX IF EXISTS idx_favorites_path;
|
||||
DROP INDEX IF EXISTS idx_tags_name;
|
||||
DROP INDEX IF EXISTS idx_tagged_photo_photo_name;
|
||||
DROP INDEX IF EXISTS idx_tagged_photo_tag_id;
|
||||
DROP INDEX IF EXISTS idx_image_exif_camera;
|
||||
DROP INDEX IF EXISTS idx_image_exif_gps;
|
||||
17
migrations/2025-12-17-230000_add_indexes/up.sql
Normal file
17
migrations/2025-12-17-230000_add_indexes/up.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- Add indexes for improved query performance
|
||||
|
||||
-- Favorites table indexes
|
||||
CREATE INDEX IF NOT EXISTS idx_favorites_userid ON favorites(userid);
|
||||
CREATE INDEX IF NOT EXISTS idx_favorites_path ON favorites(path);
|
||||
|
||||
-- Tags table indexes
|
||||
CREATE INDEX IF NOT EXISTS idx_tags_name ON tags(name);
|
||||
|
||||
-- Tagged photos indexes
|
||||
CREATE INDEX IF NOT EXISTS idx_tagged_photo_photo_name ON tagged_photo(photo_name);
|
||||
CREATE INDEX IF NOT EXISTS idx_tagged_photo_tag_id ON tagged_photo(tag_id);
|
||||
|
||||
-- EXIF table indexes (date_taken already has index from previous migration)
|
||||
-- Adding composite index for common EXIF queries
|
||||
CREATE INDEX IF NOT EXISTS idx_image_exif_camera ON image_exif(camera_make, camera_model);
|
||||
CREATE INDEX IF NOT EXISTS idx_image_exif_gps ON image_exif(gps_latitude, gps_longitude);
|
||||
Reference in New Issue
Block a user