pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron Johnson <ron.l.johnson@cox.net>
To: PgSQL Performance ML <pgsql-performance@postgresql.org>
Subject: Re: Indexing foreign keys
Date: 27 Jan 2003 15:13:32 -0600
Message-ID: <1043702012.9896.72.camel@haggis> (raw)
In-Reply-To: <3E35991D.5050704@spaceship.com>
References: <3E35991D.5050704@spaceship.com>

On Mon, 2003-01-27 at 14:39, Matt Mello wrote:
> Due to reasons that everyone can probably intuit, we are porting a large 
> server application from IBM Informix to PG.  However, things that take 
> milliseconds in IFX are taking HOURS (not joking) in PG.  I *think* I 
> may have come across some reasons why, but I would like to see if anyone 
> else has an opinion.  I could not find anything relevant in docs (but if 
> it is there, please point me to it).
> 
> Let me give an example of one of the problems...
> 
> I have a table that utilizes 2 foreign keys.  It has 400000 records of 
> approximately 512 bytes each (mostly text, except for the keys).  When I 
> run a specific query on it, it takes 8000ms to complete, and it always 
> does a full scan.
> 
> I "assumed" that since I did not have to create an index on those 
> foreign key fields in IFX, that I did not have to in PG.  However, just 
> for kicks, I created an index on those 2 fields, and my query time 
> (after the first, longer attempt, which I presume is from loading an 
> index) went from 8000ms to 100ms.
> 
> So, do we ALWAYS have to create indexes for foreign key fields in PG? 
> Do the docs say this?  (I couldn't find the info.)

When you say "I created an index on those 2 fields", so you mean on
the fields in the 400K row table, or on the keys in the "fact tables"
that the 400K row table?

Also, in IFX, could the creation of the foreign indexes have implicitly
created indexes?
The reason I ask is that this is what happens in Pg when you create a
PK.

-- 
+---------------------------------------------------------------+
| Ron Johnson, Jr.        mailto:ron.l.johnson@cox.net          |
| Jefferson, LA  USA      http://members.cox.net/ron.l.johnson  |
|                                                               |
| "Fear the Penguin!!"                                          |
+---------------------------------------------------------------+




view thread (12+ messages)  latest in thread

Message-ID: <1043702012.9896.72.camel@haggis>
Permalink:  ../1043702012.9896.72.camel@haggis/
Also on:    postgresql.org/message-id/1043702012.9896.72.camel@haggis

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: ron.l.johnson@cox.net
  Subject: Re: Indexing foreign keys
  In-Reply-To: <1043702012.9896.72.camel@haggis>
  References: <3E35991D.5050704@spaceship.com> <1043702012.9896.72.camel@haggis>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox