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 51E16329C65 for ; Thu, 16 Sep 2004 09:54:01 +0100 (BST) 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 11081-03 for ; Thu, 16 Sep 2004 08:53:50 +0000 (GMT) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by svr1.postgresql.org (Postfix) with ESMTP id 228E6329EFF for ; Thu, 16 Sep 2004 09:53:51 +0100 (BST) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1C7s1V-0008Ff-00; Thu, 16 Sep 2004 04:53:49 -0400 To: Patrick Clery Cc: pgsql-performance@postgresql.org Subject: Re: Comparing user attributes with bitwise operators References: <200409160141.37604.patrick@phpforhire.com> In-Reply-To: <200409160141.37604.patrick@phpforhire.com> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 16 Sep 2004 04:53:49 -0400 Message-ID: <87fz5ippb6.fsf@stark.xeocode.com> Lines: 35 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 200409/160 X-Sequence-Number: 8288 Patrick Clery 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