pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Stark <gsstark@mit.edu>
To: Patrick Clery <patrick@phpforhire.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Comparing user attributes with bitwise operators
Date: 16 Sep 2004 04:53:49 -0400
Message-ID: <87fz5ippb6.fsf@stark.xeocode.com> (raw)
In-Reply-To: <200409160141.37604.patrick@phpforhire.com>
References: <200409160141.37604.patrick@phpforhire.com>


Patrick Clery <patrick@phpforhire.com> writes:

> Here's the structure of the marital status table:

Also I find it very odd that you have a "marital status table". marital status
is just one attribute of member. Do you expect to have more than one marital
status bitfield per member? How would you distinguish which one to use?

It's going to make it very hard to combine criteria against other attributes
even if you do manage to get a GiST index to work against marital status and
you do the same with the other, then postgres will have to do some sort of
merge join between them. It also means you'll have to write the same code over
and over for each of these tables.

I think you're much more likely to want to merge all these attributes into a
single "member_attributes" table, or even into the member table itself. Then
your goal would be to match all the member_attribute bits against all the
member_preferred bits in the right way.

The more conventional approach is to break them out into a fact separate
table:

member_id, attribute_id

And then just have a list of pairs that apply. This kind of normalized data is
much more flexible for writing all kinds of queries against. But like you've
found, it's hard to optimize this to be fast enough for transactional use.

I think the normal approach with dating sites is to leave this for a batch job
that populates a match table for everyone and just have the web site display
the contents out of that table.

-- 
greg




view thread (12+ messages)  latest in thread

Message-ID: <87fz5ippb6.fsf@stark.xeocode.com>
Permalink:  ../87fz5ippb6.fsf@stark.xeocode.com/
Also on:    postgresql.org/message-id/87fz5ippb6.fsf@stark.xeocode.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: gsstark@mit.edu, patrick@phpforhire.com
  Subject: Re: Comparing user attributes with bitwise operators
  In-Reply-To: <87fz5ippb6.fsf@stark.xeocode.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