X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id A53B29DCBD7 for ; Sat, 3 Dec 2005 19:00:22 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07481-08 for ; Sat, 3 Dec 2005 19:00:18 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.197]) by postgresql.org (Postfix) with ESMTP id 7C82E9DCBA2 for ; Sat, 3 Dec 2005 19:00:19 -0400 (AST) Received: by zproxy.gmail.com with SMTP id 4so866377nzn for ; Sat, 03 Dec 2005 15:00:22 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=JL6g6cLT6xsN16T3XN/qeQaDAIaJEaCrN/J0x4BCXkccNIjanaGIpz7SX2/uLREKnEIXBtF2L3lWOcoz8TgVLt+hAkpgJgO70tCEBSGyjyaQv8yIx15pRjdMtUfD4vNIcgLaa10w3apWxM1pEAW/SemUF6V0KT2DqOShMXcrH68= Received: by 10.65.158.10 with SMTP id k10mr2137762qbo; Sat, 03 Dec 2005 15:00:21 -0800 (PST) Received: by 10.65.177.1 with HTTP; Sat, 3 Dec 2005 15:00:21 -0800 (PST) Message-ID: <3cf983d0512031500r2a9da709r8eb362806e91f61@mail.gmail.com> Date: Sat, 3 Dec 2005 23:00:21 +0000 From: Rodrigo Madera To: pgsql-performance@postgresql.org Subject: Faster db architecture for a twisted table. MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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: 200512/106 X-Sequence-Number: 15927 Imagine a table named Person with "first_name" and "age". Now let's make it fancy and put a "mother" and "father" field that is a reference to the own table (Person). And to get even fuzzier, let's drop in some siblings: CREATE TABLE person( id bigint PRIMARY KEY, first_name TEXT, age INT, mother bigint REFERENCES person, father biging REFERENCES person, siblings array of bigints (don't remember the syntax, but you get the p= oint) ); Well, this is ok, but imagine a search for "brothers of person id 34". We would have to search inside the record's 'siblings' array. Is this a bad design? is this going to be slow? What would be a better design to have these kind of relationships? (where you need several references to rows inside the table we are). Thanks for any help, Rodrigo