create table test2 (t text); insert into test2 values ('foo'); insert into test2 values ('bar'); create table test (t text, ts_vec tsvector); insert into test (t, ts_vec) values ('foo', to_tsvector('foo')); insert into test (t, ts_vec) values ('bar', to_tsvector('bar')); insert into test (t, ts_vec) values ('foo bar', to_tsvector('foo bar')); create index on test using gin(ts_vec); vacuum test; set enable_seqscan = off; set enable_hashjoin = off; set enable_mergejoin = off; set gin_fuzzy_search_limit = 1000; select test.t from test2, test where ts_vec @@ to_tsquery('english', 'foo') and test.t = test2.t;