X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7CBC65E46CD for ; Wed, 25 Aug 2004 13:59:44 -0300 (ADT) 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 52613-07 for ; Wed, 25 Aug 2004 16:59:34 +0000 (GMT) Received: from davinci.ethosmedia.com (server226.ethosmedia.com [209.128.84.226]) by svr1.postgresql.org (Postfix) with ESMTP id 2D9025E3631 for ; Wed, 25 Aug 2004 13:59:33 -0300 (ADT) Received: from [63.195.55.98] (HELO spooky) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 6172708 for pgsql-performance@postgresql.org; Wed, 25 Aug 2004 10:00:48 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Organization: Aglio Database Solutions To: pgsql-performance@postgresql.org Subject: Re: What is the best way to do attribute/values? Date: Wed, 25 Aug 2004 09:59:15 -0700 User-Agent: KMail/1.4.3 References: <4124EB58.9040102@sh.nu> <200408241330.32484.josh@agliodbs.com> <412C4C3A.2030001@coretech.co.nz> In-Reply-To: <412C4C3A.2030001@coretech.co.nz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200408250959.15946.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/341 X-Sequence-Number: 7977 Mark, Tim, > select > pav1.person_id > from > person_attributes_vertical pav1 > where > ( pav1.attribute_id = 1 > and pav1.value_id in (2,3)) > or ( pav1.attribute_id = 2 > and pav1.value_id in (2,3)) Not the same query, sorry. Daniel's query yields all the person_id's which have criteria A AND criteria B. Yours gives all the person_id's which have criteria A OR criteria B. > There will be a lot of attributes with the same ID; there will also be a > lot of attributes with the same value. However, there should be much less > attributes with a specific combination of (ID/Value). Right now I think it > will be very hard to determine which field has a better selectivity: > attribute_id or value_id. Given that there is already an index on ( attribute_id, value_id ) I don't quite see what difference this makes. Unless you're suggesting this as a workaround for the PG Planner's poor use of the index? -- Josh Berkus Aglio Database Solutions San Francisco