postgresql - Fast querying with gin index on table with column containing XML tags -
i have large knowledge base(yago2) columns of form of xml tags e.g. '<albert_einstein>'. performance important in use case created gin index that:
create index col_idx on yagofacts using gin(to_tsvector('english', column_name)); now trying query with
select * yagofacts to_tsvector('english', column_name) @@ to_tsquery('albert_einstein'); however, doesn't return result because can't search in xml tags. saw 1 solution previous question do:
select to_tsvector( 'simple', regexp_replace(column_name, e'[^a-za-z0-9]', ' ', 'g')) @@ to_tsquery('simple','albert_einstein'); the problem doesn't have performance because doesn't make use of gin index created. how can query fast?
i managed solve this, creating gin index on:
create index no_xml_idx on yagofacts using gin(to_tsvector('simple', regexp_replace(column_name, e'[^a-za-z0-9]', ' ', 'g')));
Comments
Post a Comment