Files
aura-crm/production/backend/migrations/008_file_key_indexes.sql
T

10 lines
548 B
SQL

-- +goose Up
-- file.Handler.Get now looks up which order/batch a given file_key belongs
-- to (see the code change alongside this migration), turning what used to
-- be zero DB work per photo view into one lookup per request. Without an
-- index that lookup is a sequential scan over every comment and photo event
-- ever logged.
CREATE INDEX IF NOT EXISTS order_events_file_key_idx ON order_events (file_key) WHERE file_key IS NOT NULL;
CREATE INDEX IF NOT EXISTS batch_events_file_key_idx ON batch_events (file_key) WHERE file_key IS NOT NULL;