Thread: Optimizer misconfigured ?

Optimizer misconfigured ?

From
Nörder-Tuitje, Marcus
Date:


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

Re: Optimizer misconfigured ?

From
Richard Huxton
Date:
Nörder-Tuitje wrote:
>
> Hello,
>
> I have a strange effect on upcoming structure :

People will be wanting the output of EXPLAIN ANALYSE on that query.

They'll also ask whether you've VACUUMed, ANALYSEd and configured your
postgresql.conf correctly.

--
   Richard Huxton
   Archonet Ltd



Re: Optimizer misconfigured ?

From
Nörder-Tuitje, Marcus
Date:
Hi,

meanwhile I have received the hint to make postgres use the index via

SET ENABLE_SEQSCAN=FALSE;

which fits perfectly. The execution plan now indicates full use of index.

Nevertheless this is merely a workaround. Maybe the io-costs are configured to cheap.

thanks :-)


-----Ursprüngliche Nachricht-----
Von: Richard Huxton [mailto:dev@archonet.com]
Gesendet: Donnerstag, 13. Oktober 2005 12:22
An: Nörder-Tuitje, Marcus
Cc: pgsql-performance@postgresql.org
Betreff: Re: [PERFORM] Optimizer misconfigured ?


Nörder-Tuitje wrote:
>
> Hello,
>
> I have a strange effect on upcoming structure :

People will be wanting the output of EXPLAIN ANALYSE on that query.

They'll also ask whether you've VACUUMed, ANALYSEd and configured your
postgresql.conf correctly.

--
   Richard Huxton
   Archonet Ltd





Re: Optimizer misconfigured ?

From
Richard Huxton
Date:
Nörder-Tuitje wrote:
> Hi,
>
> meanwhile I have received the hint to make postgres use the index via
>
>
> SET ENABLE_SEQSCAN=FALSE;
>
> which fits perfectly. The execution plan now indicates full use of
> index.

What execution plan? I still only see one message on the list.

> Nevertheless this is merely a workaround. Maybe the io-costs are
> configured to cheap.

Possibly - the explain analyse will show you.
--
   Richard Huxton
   Archonet Ltd