Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 031BC47594C for ; Tue, 26 Mar 2002 11:44:22 -0500 (EST) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.2) with HTTP id 839200; Tue, 26 Mar 2002 08:44:24 -0800 From: "Josh Berkus" Subject: Re: Arrays Design Question To: Achilleus Mantzios , pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.5.2 Date: Tue, 26 Mar 2002 08:44:24 -0800 Message-ID: In-Reply-To: <02032610121202.09965@pc216> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200203/342 X-Sequence-Number: 7217 Achilleus , > performance for the following problem: > I want to store the factors of a linear formula of unknown degree > (but less > than 10) in a table for online stats/graphs on historical data (about > 200 Mb). > I am thinking of > a) Store each formula as a float8[] array and then write a pgsql > function in C > to compute the result given the value of variable x. > b) Add 10 columns of type float8 and store 0 values where the > position of the > column exceeds the degree of the formula. BOTH of the above are poor approaches that will lead to headaches for you later on. Instead: c. Store each formula in a column in another table with a parent-child relationship to your main table, i.e. online_stats stat_formulas --------------- ------------------ online_stat_id ------------->online_stat_id formula_number formula This is basic relational database design. You should probably pick up a copy of "Relational Database Design for Mere Mortals" before you get yourself into a real mess ... -Josh Berkus