Hello,
I have a strange effect on upcoming structure :
DEX_OBJ ---< DEX_STRUCT >--- DEX_LIT
DEX_OBJ : 100 records (#DOO_ID, DOO_NAME)
DEX_STRUCT : 2,5 million records (#(DST_SEQ, FK_DOO_ID, FK_LIT_ID))
DEX_LIT : 150K records (#LIT_ID, LIT_TEXT)
(# marks primary key)
i'd like to count all LIT occurences in struct for a set of LITs.
so i indexed DEX_STRUCT using (FK_LIT_ID, FK_DOO_ID)
and i indexed DEX_LIT using BTREE (LIT_TEXT, LIT_ID)
but if i query
SELECT DOO_ID
, COUNT(FK_LIT_ID) AS occurences
FROM DEX_STRUCT STR
, DEX_LITERAL LIT
WHERE STR.FK_LIT_ID = LIT.LIT_ID
AND LIT_TEXT IN ('foo', 'bar', 'foobar')
GROUP BY DOO_ID
postgresql always runs a seq scan on DEX_STRUCT. I tried several indices and also very different kinds of queries (from EXISTS via INNER JOIN up to subqueries), but Pgsql does not use any index on dex_struct.
What can I do ? Is this a optimizer misconfiguration (hence, it is still in default config) ?
How can I make Pg using the indices on doc_struct ? The index on LIT is used :-(
I expect 30 - 60 millions of records in the struct table, so I urgently need indexed access.
Thanks a lot !
Marcus