-- payment-history lists newest-first (ORDER BY p.id DESC) and is commonly -- filtered to one gateway_status; without this, a rare status (e.g. -- pending) means walking the whole primary key backwards to fill a page. CREATE INDEX IF NOT EXISTS idx_visa_master_order_payments_status_id ON visa_master_order_payments (gateway_status, id DESC) WHERE deleted_at IS NULL;