【发布时间】:2019-05-20 05:52:47
【问题描述】:
我对 PostgreSQL 很陌生,所以如果我问的很明显,我很抱歉。
我有一张名为customer_products 的表。它包含以下两个索引:
CREATE INDEX customer_products_customer_id
ON public.customer_products USING btree (customer_id)
CREATE UNIQUE INDEX customer_products_customer_id_product_id
ON public.customer_products USING btree (customer_id, product_id)
对于customer_id,它们是否都在做同样的事情,或者它们的功能是否不同?我不确定是应该留下它们还是删除customer_products_customer_id。
【问题讨论】:
-
我不知道索引和唯一索引之间的区别,但显然你提到的两个索引位于不同的列上,所以它们不太可能做同样的事情。
标签: postgresql indexing query-performance