diff --git a/backend/migrations/20260405151839_add_resource_cache_expire_index.down.sql b/backend/migrations/20260405151839_add_resource_cache_expire_index.down.sql new file mode 100644 index 0000000000..8e71d40f0b --- /dev/null +++ b/backend/migrations/20260405151839_add_resource_cache_expire_index.down.sql @@ -0,0 +1 @@ +DROP INDEX IF EXISTS idx_resource_cache_expire; diff --git a/backend/migrations/20260405151839_add_resource_cache_expire_index.up.sql b/backend/migrations/20260405151839_add_resource_cache_expire_index.up.sql new file mode 100644 index 0000000000..dd3a5989cc --- /dev/null +++ b/backend/migrations/20260405151839_add_resource_cache_expire_index.up.sql @@ -0,0 +1,5 @@ +-- Partial functional index to speed up periodic cleanup of expired cache resources. +-- Matches the query: DELETE FROM resource WHERE resource_type = 'cache' AND to_timestamp((value->>'expire')::int) < now() +CREATE INDEX IF NOT EXISTS idx_resource_cache_expire + ON resource (to_timestamp((value->>'expire')::int)) + WHERE resource_type = 'cache';