From: | Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> |
---|---|
To: | PgSQL Performance ML <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Indexing foreign keys |
Date: | 2003-01-27 21:13:32 |
Message-ID: | 1043702012.9896.72.camel@haggis |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-performance |
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(dot)l(dot)johnson(at)cox(dot)net |
| Jefferson, LA USA http://members.cox.net/ron.l.johnson |
| |
| "Fear the Penguin!!" |
+---------------------------------------------------------------+
From | Date | Subject | |
---|---|---|---|
Next Message | Luke Pascoe | 2003-01-27 21:13:42 | Re: Inherited tables and NOT NULL (pg 7.2.1) |
Previous Message | lchan | 2003-01-27 21:12:20 | problems getting a module installed |
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2003-01-27 21:16:49 | Re: Indexing foreign keys |
Previous Message | Josh Berkus | 2003-01-27 21:12:09 | Re: Indexing foreign keys |