[horde] Looking for a Suggestion for a SQL select change

Chuck Hagenbuch chuck at horde.org
Wed Jan 3 21:22:57 PST 2007


Quoting James MacLean <macleajb at ednet.ns.ca>:

> This is an example query from horde that is causing backups on MySQL :
>
> SELECT c.datatree_id, c.datatree_name FROM horde_datatree c LEFT JOIN
> horde_datatree_attributes a1 ON a1.datatree_id = c.datatree_id WHERE
> c.group_uid = 'horde.shares.kronolith' AND ((a1.attribute_name =
> 'owner' AND a1.attribute_value = 'somone at here.com') OR
> (a1.attribute_name = 'perm_users' AND a1.attribute_key =
> 'someone at here.com' AND a1.attribute_value & 2) OR (a1.attribute_name
> = 'perm_creator' AND a1.attribute_value & 2) OR (a1.attribute_name =
> 'perm_default' AND a1.attribute_value & 2))   GROUP BY c.datatree_id,
> c.datatree_name, c.datatree_order ORDER BY c.datatree_order,
> c.datatree_name, c.datatree_id

The code in CVS runs OR queries one at a time for this same reason  
(see revisions 1.219 and 1.220 here:  
http://cvs.horde.org/framework/DataTree/DataTree/sql.php ). It hasn't  
been merged to a stable branch yet because it's a moderately major  
change, but if it tests out well for everyone it'll definitely be in  
Horde 3.2.

Does that work for you? It's essentially the same as the UNION query.

-chuck

--
"we are plastered to the windshield of the bus that is time." - Chris


More information about the horde mailing list