Re: What is the best way to do attribute/values?

From: Jeff <threshar(at)torgo(dot)978(dot)org>
To: Mark Kirkwood <markir(at)coretech(dot)co(dot)nz>
Cc: Daniel Ceregatti <vi(at)sh(dot)nu>, pgsql-performance(at)postgresql(dot)org, Josh Berkus <josh(at)agliodbs(dot)com>
Subject: Re: What is the best way to do attribute/values?
Date: 2004-08-25 12:36:07
Message-ID: 564D90B0-F693-11D8-AAA9-000D9366F0C4@torgo.978.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


On Aug 25, 2004, at 4:22 AM, Mark Kirkwood wrote:

> 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))
>

You know..
It may help if you toss in a group by
ie

select pav1.person_id, count(*) from person_attributes_vertical pav1
where (pav1.attribute_id = 1 and pav1.value_id in (2,3)) or ( ... ) or
(...)
group by pav1.person_id
order by count(*) desc

that should give you the person_id's that matched the most
criteria........
I've used similar things before now that I've thought about it.

If you want an exact match you could put
"having count(*) = $myNumAttributes" in there too.. By definition an
exact match would match that definition..

it has an added side effect of producing "closest matches" when an
exact match cannot be found... granted you may not want that for a
dating site : )

"You asked for a blond female, blue eyes.. but I couldn't find any...
but I *DID* find a brown haired male with brown eyes! Is that good
enough?"

--
Jeff Trout <jeff(at)jefftrout(dot)com>
http://www.jefftrout.com/
http://www.stuarthamm.net/

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Leeuw van der, Tim 2004-08-25 13:05:56 Re: What is the best way to do attribute/values?
Previous Message Leeuw van der, Tim 2004-08-25 11:26:00 OT: Network config (WAS: RE: postgresql performance with multimedia)