PostgreSql: how to create index for character varying array type column -


my table structure

create table product (   id bigserial not null,   seller_id integer,   product_data  character varying[],   ptype integer,   constraint config_pkey primary key (id) ) 

index created: create index product_name_idx on product using gin (product_data);

proudct_data column can have around 50 different product names @ max in array , product table has around 1m unique rows. need find out seller_id s have 'steel' product, 'steel' may sub-string of product name in product_data;

currently using following query:

 select * product ptype in ( 2,3 ) , '%steel%' % any(product_data) offset 0 limit 10; 

the above query gives expected results, not using product_name_idx index, slow. how can create proper index on column? please me out.

i thought gin indexes work on tsvector data types?

alter product_data tsvector type, recreate index , ensure cast tsvector on query:

select * product ptype in ( 2,3 ) , '%steel%'::tsvector % any(product_data) offset 0 limit 10; 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -