Re: [GENERAL] Indexing queries with bit masks

2010-05-02 Thread Mike Christensen
Hey thanks.. I thought I'd share the method I came up with for updating subscriptions. Basically, as far as my code is concerned the DB uses a bitmask (at least for updates) but I abstract it through a function. First off, I have a little helper function so I don't repeat the same code a bunch

Re: [GENERAL] Indexing queries with bit masks

2010-05-01 Thread Filip Rembiałkowski
2010/4/30 Mike Christensen m...@kitchenpc.com: Ok I've been blatantly lying, err, purposely simplifying the problem for the sake of the original email :) I've read over the responses, and am actually now considering just not using any index at all.  Here's why: First, this actually isn't

[GENERAL] Indexing queries with bit masks

2010-04-30 Thread Mike Christensen
I want a column in my Users table that will keep track of which types of notifications the user wants to subscribe to. There's probably about 10 different types, so I don't want to have 10 boolean columns because this seems kinda hacky and makes adding new types more work. So I'm thinking about

Re: [GENERAL] Indexing queries with bit masks

2010-04-30 Thread Tom Lane
Mike Christensen m...@kitchenpc.com writes: When a certain event happens, let's say event 4, I need to query for which users to notify. So I'll be doing something like: SELECT UserId FROM Users WHERE Subscriptions 8; My question is say there's a million rows in the Users table. If I have

Re: [GENERAL] Indexing queries with bit masks

2010-04-30 Thread Peter Hunsberger
On Fri, Apr 30, 2010 at 10:08 AM, Tom Lane t...@sss.pgh.pa.us wrote: Mike Christensen m...@kitchenpc.com writes: When a certain event happens, let's say event 4, I need to query for which users to notify.  So I'll be doing something like: SELECT UserId FROM Users WHERE Subscriptions 8; My

Re: [GENERAL] Indexing queries with bit masks

2010-04-30 Thread Tom Lane
Peter Hunsberger peter.hunsber...@gmail.com writes: If all subscriptions are roughly equal in popularity then any single select should give ~ 10% of the data. That would seem to be selective enough that you'd really want an index? My personal rule of thumb is that 10% is around the threshold

Re: [GENERAL] Indexing queries with bit masks

2010-04-30 Thread Peter Hunsberger
On Fri, Apr 30, 2010 at 11:29 AM, Tom Lane t...@sss.pgh.pa.us wrote: Peter Hunsberger peter.hunsber...@gmail.com writes: If all subscriptions are roughly equal in popularity then any single select should give ~ 10% of the data.  That would seem to be selective enough that you'd really want an

Re: [GENERAL] Indexing queries with bit masks

2010-04-30 Thread Mike Christensen
Ok I've been blatantly lying, err, purposely simplifying the problem for the sake of the original email :) I've read over the responses, and am actually now considering just not using any index at all. Here's why: First, this actually isn't the only thing on the WHERE clause. It will only