Indexing Null Values in PostgreSQL

后端 未结 5 1929
暗喜
暗喜 2021-02-12 03:32

I have a query of the form:

select m.id from mytable m
left outer join othertable o on o.m_id = m.id
    and o.col1 is not null and o.col2 is not null and o.col3         


        
5条回答
  •  旧时难觅i
    2021-02-12 04:16

    You could try a partial index:

    CREATE INDEX idx_partial ON othertable (m_id)
    WHERE (col1 is not null and col2 is not null and col3 is not null);
    

    From the docs: http://www.postgresql.org/docs/current/interactive/indexes-partial.html

提交回复
热议问题