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
informationtechnology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small
businesses fax 621-2533 and non-profit organizations. San Francisco