feat: add index for active product categories by parent and name

This commit is contained in:
BXY 2026-10-08 15:06:22 +08:00
parent 6f6887f0d2
commit 9567b967b2

View File

@ -426,7 +426,8 @@ CREATE TABLE IF NOT EXISTS product.product_category (
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
deleted_at TIMESTAMPTZ deleted_at TIMESTAMPTZ
); );
CREATE UNIQUE INDEX IF NOT EXISTS uq_product_category_active_parent_name
CREATE INDEX IF NOT EXISTS idx_product_category_active_parent_name
ON product.product_category (COALESCE(parent_id, 0), lower(btrim(name))) WHERE deleted_at IS NULL; ON product.product_category (COALESCE(parent_id, 0), lower(btrim(name))) WHERE deleted_at IS NULL;
CREATE INDEX IF NOT EXISTS idx_product_category_active_parent_priority CREATE INDEX IF NOT EXISTS idx_product_category_active_parent_priority
ON product.product_category (parent_id, priority, id) WHERE deleted_at IS NULL; ON product.product_category (parent_id, priority, id) WHERE deleted_at IS NULL;