Files
play-life/play-life-backend/migrations/000003_add_reward_configs_covering_index.up.sql
poignatov 41aed56689
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m28s
4.0.5: Добавлен covering index для reward_configs
2026-01-26 18:20:52 +03:00

15 lines
865 B
SQL

-- Migration: Add covering index for reward_configs to optimize subtask rewards queries
-- Date: 2026-01-26
--
-- This migration adds a covering index to optimize queries that load rewards for multiple subtasks.
-- The index includes all columns needed for the query, allowing PostgreSQL to perform
-- index-only scans without accessing the main table.
--
-- Covering index for reward_configs query
-- Includes all columns needed for rewards selection to avoid table lookups
CREATE INDEX IF NOT EXISTS idx_reward_configs_task_id_covering
ON reward_configs(task_id, position)
INCLUDE (id, project_id, value, use_progression);
COMMENT ON INDEX idx_reward_configs_task_id_covering IS 'Covering index for rewards query - includes all selected columns to avoid table lookups. Enables index-only scans for better performance when loading rewards for multiple tasks.';