X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DBFA2D1ED9A for ; Thu, 29 Apr 2004 17:47:31 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 69735-09 for ; Thu, 29 Apr 2004 17:47:12 -0300 (ADT) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 169C8D1E964 for ; Thu, 29 Apr 2004 17:47:10 -0300 (ADT) Received: from [64.81.245.111] (HELO 192.168.1.102) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 4975391; Thu, 29 Apr 2004 13:48:24 -0700 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Roelant Ossewaarde , Richard Huxton Subject: Re: Use arrays or not? Date: Thu, 29 Apr 2004 13:47:16 -0700 User-Agent: KMail/1.5.4 Cc: pgsql-sql@postgresql.org References: <20040429164059.GC24558@belboek.com> <40914CC2.6050909@archonet> <20040429202631.GB25328@belboek.com> In-Reply-To: <20040429202631.GB25328@belboek.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200404291347.16488.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=RCVD_NUMERIC_HELO X-Spam-Level: X-Archive-Number: 200404/324 X-Sequence-Number: 17699 Roelant, > So, let me rephrase my questions: > 1. When and why would anyone use arrays? When the data itself is an ordered set of items which is indivisible and lacks meaning outside the ordered set. For example, a set of ordered pairs of molecules in a gene snippet. Or a mathematical matrix. > 2. When designing the database, is it really true that there is no performance > difference between a table of which the number of tuples grow by a factor of, > say 10, and a table of which the size of the tuples grow by a factor of, say > 10? Nobody's tested anything. I would *tend* to think that PostgreSQL would handle more-of-less-wide-rows somewhat better, but that's just a guess. Hmmm ... not completely a guess. Postgres, by default, compresses fields over 8K in size (see TOAST in the docs). This makes those fields somewhat slower to update. So if 1 XML rec < 8k but 4 XML rec > 8k, there could be a small-but-noticeable performance loss from going to "broad" rows. If I had your application, I would not go for the array approach, jjust to avoid maintainence headaches. For example, what happens when the books start having a variable number of XML records? Normalized designs are almost always easier to deal with from a perspective of long-term maintainence. The arrays, as far as I can tell, gain you nothing in ethier performance or convenience. -- -Josh Berkus Aglio Database Solutions San Francisco