pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
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
Message-ID: <200408250959.15946.josh@agliodbs.com> (raw)
In-Reply-To: <412C4C3A.2030001@coretech.co.nz>
References: <4124EB58.9040102@sh.nu>
	<200408241330.32484.josh@agliodbs.com>
	<412C4C3A.2030001@coretech.co.nz>

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



view thread (9+ messages)  latest in thread

Message-ID: <200408250959.15946.josh@agliodbs.com>
Permalink:  ../200408250959.15946.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200408250959.15946.josh@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: josh@agliodbs.com
  Subject: Re: What is the best way to do attribute/values?
  In-Reply-To: <200408250959.15946.josh@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox