Re: foreign key constraint, planner ignore index.

From: Richard Huxton <dev(at)archonet(dot)com>
To: Andrew Nesheret <andrew(at)infinet(dot)ru>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: foreign key constraint, planner ignore index.
Date: 2007-12-19 09:09:51
Message-ID: 4768DFDF.3050904@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Andrew Nesheret wrote:
>
> And if i'm execute same statement without access to nodes table planer
> chose to use index "fki_nodes"!!!
>
> explain analyze SELECT 1 FROM ONLY "public"."sf_ipv4traffic" x WHERE
> 2003 OPERATOR(pg_catalog.=) "node" FOR SHARE OF x;
>
> QUERY
> PLAN
> ----------------------------------------------------------------------------------------------------------------------------
>
> Index Scan using fki_nodes on sf_ipv4traffic x (cost=0.00..9.65 rows=1
> width=6) (actual time=0.019..0.019 rows=0 loops=1)
> Index Cond: (2003 = node)
> Total runtime: 0.089 ms
> (3 rows)

If you PREPARE .... then EXECUTE the same query, does it still use the
index? The only thing I can think of is that the trigger is planning the
query to work for any given value and you have a lot of rows with e.g.
node=2004.

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Nesheret 2007-12-19 10:21:57 Re: foreign key constraint, planner ignore index.
Previous Message Pedro Doria Meunier 2007-12-19 09:02:31 Re: thank you