X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6DAD2DA047 for ; Wed, 9 Nov 2005 15:28:33 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 38857-04 for ; Wed, 9 Nov 2005 19:28:29 +0000 (GMT) X-Greylist: delayed 03:13:36.491418 by SQLgrey- Received: from svr2.postgresql.org (svr2.postgresql.org [65.19.161.25]) by svr1.postgresql.org (Postfix) with ESMTP id C9653D9F36 for ; Wed, 9 Nov 2005 15:28:28 -0400 (AST) Received: from mirage.dsl.net (mirage.dsl.net [65.84.81.14]) by svr2.postgresql.org (Postfix) with ESMTP id 81C7DF0AC7 for ; Wed, 9 Nov 2005 16:14:50 +0000 (GMT) Received: from zack (ppp-69-238-231-50.dsl.pltn13.pacbell.net [69.238.231.50]) by mirage.dsl.net (Postfix) with ESMTP id 345C437E61 for ; Wed, 9 Nov 2005 11:14:45 -0500 (EST) From: "Zack Chandler" To: Subject: Re: Design question: Scalability and tens of thousands of Date: Wed, 9 Nov 2005 08:14:36 -0800 Message-ID: <006f01c5e548$afc1d910$0200a8c0@aaaadp.local> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 In-Reply-To: <20051108211444.0db037d6.gry@ll.mit.edu> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/80 X-Sequence-Number: 23331 I have thought of this as a possible solution. Unfortunately I want to = do reporting (sum, avg, ect.) queries on this data (for each user) and I = can't imagine that being feasible with casting that many columns. Zack -----Original Message----- From: pgsql-sql-owner@postgresql.org = [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of george young Sent: Tuesday, November 08, 2005 6:15 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] Design question: Scalability and tens of thousands of On Thu, 3 Nov 2005 09:58:29 -0800 "zackchandler" threw this fish to the = penguins: > I'm designing an application that will allow users to create custom objects > on the application level. A custom object can have zero or more attributes. > Attributes can be one of 5-10 types (ex. String, Number, List, Date, = Time, > Currency, etc...). This will allow users to track anything exactly as = they > want. My first thought on how to structure this is to make a custom = table > in the db for each custom object. The attributes would map to fields = and > everything would work just dandy. >=20 > The problem is I am very concerned about scalability with having a different > table created for each custom object. I want to design to site to = handle > tens of thousands of users. If each user has 3-5 custom objects the > database would have to handle tens of thousands of tables. >=20 > So it would appear that this is a broken solution and will not scale. = Has > anyone designed a similar system or have ideas to share? This is a sticky problem. My app is a bit similar. Trying something like your solution, I found that zillions of tables, constantly created and destroyed by users, to be terrible to manage. Now I use one table that defines objects' attributes, e.g. something like: create table fields(owner text, obj text, name text, type text, seq = int) create table objs(owner text, name text) create table values(owner text, obj text, name text, val text) That is, the values are stored in text type, not the native type. Yes, this takes a performance hit for conversion of values, but the simplicity of schema really wins for me. I suggest you seriously = consider it unless you need blinding performance in all 20,000 applications... -- George Young --=20 "Are the gods not just?" "Oh no, child. What would become of us if they were?" (CSL) ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match