Re: foreign key constraint, planner ignore index. - Mailing list pgsql-general

From Richard Huxton
Subject Re: foreign key constraint, planner ignore index.
Date
Msg-id 4768DFDF.3050904@archonet.com
Whole thread Raw
In response to foreign key constraint, planner ignore index.  (Andrew Nesheret <andrew@infinet.ru>)
Responses Re: foreign key constraint, planner ignore index.
List 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

pgsql-general by date:

Previous
From: Johan van Zyl
Date:
Subject: to realise the dark side of Microsoft SQL Server...?
Next
From: Andrew Nesheret
Date:
Subject: Re: foreign key constraint, planner ignore index.