The following is an example of using an index. Run the following statements in a database that uses the UTF-8 or GBK encoding:
1 2 3 4 5 6 7 8 9 10 11 12 13 | create table table1 (c_int int,c_bigint bigint,c_varchar varchar,c_text text) with(orientation=row); create text search configuration ts_conf_1(parser=POUND); create text search configuration ts_conf_2(parser=POUND) with(split_flag='%'); set default_text_search_config='ts_conf_1'; create index idx1 on table1 using gin(to_tsvector(c_text)); set default_text_search_config='ts_conf_2'; create index idx2 on table1 using gin(to_tsvector(c_text)); select c_varchar,to_tsvector(c_varchar) from table1 where to_tsvector(c_text) @@ plainto_tsquery('¥#@……&**') and to_tsvector(c_text) @@ plainto_tsquery('Company') and c_varchar is not null order by 1 desc limit 3; |
In this example, table1 has two GIN indexes created on the same column c_text, idx1 and idx2, but these two indexes are created under different settings of default_text_search_config. Differences between this example and the scenario where one table has common indexes created on the same column are as follows:
As a result, using idx1 and idx2 for the same query returns different results.
In the preceding example, when:
To avoid different query results caused by different GIN indexes, ensure that only one GIN index is available on a column of the physical table.