alternative to bitmap index in postgresql

后端 未结 3 875
野趣味
野趣味 2021-01-19 19:06

I have a table with hundreds of millions rows with schema like below.

tabe AA {
 id integer primay key,
 prop0 boolean not null,
 prop1 boolean not null,
 p         


        
3条回答
  •  悲哀的现实
    2021-01-19 19:54

    Create a multicolumn index on properties which are always or almost always queried. Or several multicolumn indexes if needed.

    The alternative, when you do not query the same properties almost always, is to make a tsvector column with words describing your data, maintained using trigger, for example

    prop0=true
    prop1=false
    prop2=4
    

    would be

    'propzero nopropone proptwo4'::tsvector
    

    index it using GIN and then use full text search for searching:

    where tsv @@ 'popzero & nopropone & proptwo4'::tsquery
    

提交回复
热议问题