Re: [SQL] SQL Query Performance - what gives?

From: Pierre Frédéric Caillaud <lists(at)peufeu(dot)com>
To: "Karl Denninger" <karl(at)denninger(dot)net>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>, pgsql-performance(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] SQL Query Performance - what gives?
Date: 2009-08-19 06:27:52
Message-ID: op.uywb8qyucke6l8@soyouz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance pgsql-sql


> The bitmask allows the setting of multiple permissions but the table
> definition doesn't have to change (well, so long as the bits fit into a
> word!) Finally, this is a message forum - the actual code itself is
> template-driven and the bitmask permission structure is ALL OVER the
> templates; getting that out of there would be a really nasty rewrite,
> not to mention breaking the user (non-developer, but owner)
> extensibility of the current structure.
>
> Is there a way to TELL the planner how to deal with this, even if it
> makes the SQL non-portable or is a hack on the source mandatory?

You could use an integer array instead of a bit mask, make a gist index
on it, and instead of doing "mask & xxx" do "array contains xxx", which is
indexable with gist. The idea is that it can get much better row
estimation. Instead of 1,2,3, you can use 1,2,4,8, etc if you like. you'd
probably need a function to convert a bitmask into ints and another to do
the conversion back, so the rest of your app gets the expected bitmasks.
Or add a bitmask type to postgres with ptoper statistics...

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Ivan Voras 2009-08-19 10:19:17 Re: SQL Query Performance - what gives?
Previous Message Karl Denninger 2009-08-19 02:47:57 Re: [SQL] SQL Query Performance - what gives?

Browse pgsql-sql by date

  From Date Subject
Next Message Otniel Michael 2009-08-19 09:22:21 Ask To Optimize Looping
Previous Message Karl Denninger 2009-08-19 02:47:57 Re: [SQL] SQL Query Performance - what gives?