success=# create index indexedsearchword_cu_index on indexedsearchword (customerunit_id); CREATE INDEX success=# explain analyse SELECT DISTINCT t0.WORD FROM SEARCHWORD t0, INDEXEDSEARCHWORD_SEARCHWORD t2, INDEXEDSEARCHWORD t1 WHERE (((t1.CUSTOMERUNIT_ID = 102) AND (t0.WORD LIKE 'n%')) AND ((t2.IndexedSearchWord_ID = t1.ID) AND (t0.ID = t2.words_ID))) ORDER BY t0.WORD ASC; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------- Unique (cost=359020.19..366283.69 rows=267894 width=18) (actual time=11784.289..13004.879 rows=196134 loops=1) -> Sort (cost=359020.19..362651.94 rows=1452700 width=18) (actual time=11784.287..12685.915 rows=798087 loops=1) Sort Key: t0.word -> Hash Join (cost=16687.05..150750.13 rows=1452700 width=18) (actual time=986.173..7296.785 rows=798087 loops=1) Hash Cond: (t2.indexedsearchword_id = t1.id) -> Hash Join (cost=12519.76..98560.63 rows=1476824 width=26) (actual time=470.223..5374.936 rows=808035 loops=1) Hash Cond: (t2.words_id = t0.id) -> Seq Scan on indexedsearchword_searchword t2 (cost=0.00..32318.93 rows=2034893 width=16) (actual time=25.893..835.154 rows=2034893 loops=1) -> Hash (cost=7339.09..7339.09 rows=267894 width=26) (actual time=444.216..444.216 rows=268991 loops=1) -> Seq Scan on searchword t0 (cost=0.00..7339.09 rows=267894 width=26) (actual time=0.080..237.640 rows=268991 loops=1) Filter: ((word)::text ~~ 'n%'::text) -> Hash (cost=2703.14..2703.14 rows=86652 width=8) (actual time=291.660..291.660 rows=86406 loops=1) -> Seq Scan on indexedsearchword t1 (cost=0.00..2703.14 rows=86652 width=8) (actual time=0.790..73.862 rows=86406 loops=1) Filter: (customerunit_id = 102) Total runtime: 13692.048 ms (15 rows) success=# show lc_ctype; lc_ctype ---------- C (1 row)