6
我有以下结构。在Postgresql中有重复索引有没有什么坏处?
CREATE TABLE join_table (
id integer NOT NULL,
col_a integer NOT NULL,
col_b integer NOT NULL
)
CREATE INDEX index_on_col_a ON join_table USING btree (col_a);
CREATE INDEX index_on_col_b ON join_table USING btree (col_b);
CREATE UNIQUE INDEX index_on_col_a_and_col_b ON join_table USING btree (col_a, col_b);
col_a和col_b上还有外键。
很明显index_on_col_a
不再需要, 但是有没有保留或删除它的成本或收益?
我的猜测是,
- 保持,如果我把它
好像你已经知道答案了吗? – Andomar 2012-03-21 09:26:42
嗯...我应该避免猜疑问题吗?也许有人拥有比猜测更坚定的东西。 – 2012-03-21 09:29:06
这取决于情况,更好的写性能或查询性能 但是从我个人的观点来看,我们需要drop index index_on_col_a – francs 2012-03-21 09:38:45