What is distribution of records by codgrupousuario field?
There are lots of documents in common between diferent user groups (codgrupousuario = user group id), but each user groups can access a subset of documents based on the types of document and data sources (fontes) they are allowed to use.
You can use multi-column index (with contrib/btree_gist):
create index fti on qrydocumentos using gist (codgrupousuario, conteudo_stem_ix);
or partial index
create index fti on qrydocumentos using gist (conteudo_stem_ix) where codgrupousuario = 1;
I´d rather not create partial index (I would have to create a trigger that creates an index each time a row is inserted on codgrupousuario). But I'll try it to see how it performs.
The multi-column index seems a good idea.
One more. Let you use ispell dictionary ( I suppose, for Portuguese language, http://fmg-www.cs.ucla.edu/geoff/ispell-dictionaries.html#Portuguese-dicts )
I'll make some tests with ispell, thanks for the advices.
My Regards,
-- Diogo Biazus diogo@ikono.com.br http://www.ikono.com.br
---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match