PostgreSQL does not use a partial index

后端 未结 3 1464
無奈伤痛
無奈伤痛 2020-12-06 13:48

I have a table in PostgreSQL 9.2 that has a text column. Let\'s call this text_col. The values in this column are fairly unique (may contain 5-6 du

3条回答
  •  甜味超标
    2020-12-06 13:53

    A partial index is only used if the WHERE conditions match. Thus an index with WHERE text_col IS NOT NULL can only be used if you use the same condition in your SELECT. Collation mismatch could also cause harm.

    Try the following:

    1. Make a simplest possible btree index CREATE INDEX foo ON table (text_col)
    2. ANALYZE table
    3. Query

提交回复
热议问题