On 2012-05-04 14:31, DrYSG wrote:
> My users are presented with a list of checkbox for 4 different
> attributes
> (e.g. type of image, country, etc.)
>
> For type of image they can choose JPG, PNG, JP2000, etc. or turn off
> the
> check box.
>
> My naive implementation would have a WHERE clause with over 40
> different
> tests (type='JPG' OR type='PNG' OR country='USA' ...)
>
> There has to be an more efficient way to do this (and gives better
> hints to
> the PLANNER).
Besides the bitmask already mentioned, you can also do something like
this:
(type IN ( 'JPG', 'PNG' ) OR country='USA')
Which might simplify things for you a bit. See:
http://www.postgresql.org/docs/9.1/interactive/functions-comparisons.html
Daniel T. Staal
---------------------------------------------------------------
This email copyright the author. Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes. This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------