Re: Table design issue....

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: pierre(at)kahuna(dot)versions(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Table design issue....
Date: 2001-06-11 19:09:41
Message-ID: web-70353@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Pierre,

> In all honesty, I can't imagine ever having to join all of that
> tables at once.
> I had considered creating an attribute table previously, but was
> concerned
> about performance when working to retrieve large numbers of records.

A lot of optimization will be necessessary if you are talking over a
million records (or over 100,000 on a slow server). But spreading out
the data over several tables will force you to make a *lot* of LEFT
JOINs, which sure doesn't help your performance either.

> Perhaps, the best idea is the one I tried to not use, and that is a
> seperate
> table that contains a copy of all of the attribute's that have the
> specified type. sort of a lookaside table. I was just concenred with
> referential integrity.

Ah. I see what you're getting at. Why not use a view, rather than a
lookup table? I think that this might overcome your performance issues:

CREATE VIEW vw_table_attributes_C AS
SELECT tableid, attribute_type
FROM attributes
WHERE attribute_type = 'C'
GROUP BY tableid, attribute_type;

SELECT tableid, table_data
FROM tables JOIN vw_table__attributes_C USING tableid;

This prevents the duplication of data tables, plus gives you the
optimization inherent in a view. With regular VACUUM ANALYZE, this
should solve your perfromance problems.

-Josh

______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco

Browse pgsql-sql by date

  From Date Subject
Next Message JWR 2001-06-11 20:37:42 Re: update from another table
Previous Message Michael Richards 2001-06-11 19:03:29 Re: finding a maximum or minimum sum