Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5BJ9hE49530 for ; Mon, 11 Jun 2001 15:09:43 -0400 (EDT) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.1) with HTTP id 70353; Mon, 11 Jun 2001 12:09:41 -0700 From: "Josh Berkus" Subject: Re: Table design issue.... To: pierre@kahuna.versions.com Cc: pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.4.1 Date: Mon, 11 Jun 2001 12:09:41 -0700 Message-ID: In-Reply-To: <20010611175423.20147.qmail@kahuna.versions.com> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200106/168 X-Sequence-Number: 3391 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@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco