-- ─── Index gallery images by their parent gallery (O1) ────────────────────── -- gallery.i_project_id is filtered on every gallery view (db_gallery_images) and -- on delete, but had no index → full table scan. Add one. ALTER TABLE `gallery` ADD INDEX IF NOT EXISTS `idx_gallery_project` (`i_project_id`);