Selecting with a large number of foreign keys

From: Matt Behrens <matt(at)iserv(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Selecting with a large number of foreign keys
Date: 1999-05-04 20:47:43
Message-ID: 372F5CEF.40A8B29@iserv.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I didn't get any answers from the -novice list, maybe you folks know?

In my call tracking database, I have quite a few fields that are numbers
representing primary keys in a number of smaller tables; these are used
when there is a drop-down list of choices that someone can pick from.

My problem is that when I do reports on these, I want to see the name of
the selection instead of the number. I tried doing this with the
following query (which seems to work well for a small number of these
fields):

SELECT call_table.field_one,
call_table.field_two,
field_three_table.name AS field_three
WHERE field_three_table.id = call_table.field_three;

However, when I start doing this with a LOT of fields, I notice the
backend process growing extremely large (just pulling up all the calls
for two days with 20 fields selected resulting in the backend growing >
50 MB and taking a loooong time.) Is there a better way to do these?

--
Matt Behrens <matt(at)iserv(dot)net>
Network Operations Center, The Iserv Company

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Ross J. Reedstrom 1999-05-04 21:08:04 Re: [SQL] Selecting with a large number of foreign keys
Previous Message Ross J. Reedstrom 1999-05-04 18:06:56 Re: [SQL] How to find SQL Functions