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-20 08:29:29
Message-ID: 476A27E9.8050204@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Andrew Nesheret wrote:
> Richard Huxton wrote:
>> Andrew Nesheret wrote:
>>> Richard Huxton wrote:
>>>> If you PREPARE .... then EXECUTE the same query, does it still use
>>>> the index?
> Tested, comments?
>
> --- code -----
>
> --- result ---
> Result for node #2007
> Index Scan using fki_nodes on sf_ipv4traffic x (cost=0.00..9.65 rows=1
> width=6) (actual time=0.060..0.060 rows=0 loops=1)
> Index Cond: ($1 = node)
> Total runtime: 0.131 ms
> Result for node #156
> Seq Scan on sf_ipv4traffic x (cost=0.00..360281.29 rows=15795383
> width=6) (actual time=0.048..108939.142 rows=15795376 loops=1)
> Filter: ($1 = node)
> Total runtime: 365989.953 ms

Since you are getting different plans, this can't be a planned query.
Just try feeding a text-file with some SQL PREPARE/EXECUTEs to psql -
you can EXPLAIN ANALYSE EXECUTE ...

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Wolfgang Keller 2007-12-20 09:40:34 Re: Composite types for composite primary/foreign keys?
Previous Message Richard Huxton 2007-12-20 08:27:35 Re: Trouble running PostgreSQL server / Server must be started under certain locale.