[vhffs-dev] [964] seb found a (slight) faster query than mine, using it ! |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 964
Author: gradator
Date: 2007-10-05 20:51:23 +0000 (Fri, 05 Oct 2007)
Log Message:
-----------
seb found a (slight) faster query than mine, using it !
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Acl.pm
Modified: trunk/vhffs-api/src/Vhffs/Acl.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Acl.pm 2007-10-05 19:19:58 UTC (rev 963)
+++ trunk/vhffs-api/src/Vhffs/Acl.pm 2007-10-05 20:51:23 UTC (rev 964)
@@ -200,20 +200,10 @@
return undef unless( defined $vhffs && defined $object );
my $sth = $vhffs->get_db_object->prepare( '
- (
- ( SELECT allusers.object_id AS granted_oid, allusers.name, aclusers.perm
- FROM
- ( SELECT u.object_id, u.username AS name FROM vhffs_users u INNER JOIN vhffs_user_group ug ON ug.uid=u.uid INNER JOIN vhffs_groups g ON ug.gid=g.gid INNER JOIN vhffs_object o ON o.owner_gid=g.gid WHERE o.object_id=? )
- AS allusers
- LEFT OUTER JOIN
- ( SELECT acl.granted_oid, acl.perm FROM vhffs_acl acl INNER JOIN vhffs_users u ON u.object_id=acl.granted_oid WHERE acl.target_oid=? )
- AS aclusers
- ON allusers.object_id=aclusers.granted_oid
- )
- UNION
- ( SELECT acl.granted_oid, NULL AS name, acl.perm FROM vhffs_acl acl INNER JOIN vhffs_groups g ON acl.granted_oid=g.object_id WHERE acl.target_oid=? )
- )
- ORDER BY name ASC
+ ( SELECT u.object_id AS granted_oid, u.username AS name, aclu.perm FROM vhffs_users u INNER JOIN vhffs_user_group ug ON ug.uid=u.uid INNER JOIN vhffs_object o ON o.owner_gid=ug.gid LEFT OUTER JOIN vhffs_acl aclu ON aclu.granted_oid=u.object_id WHERE (aclu.target_oid=? OR aclu.target_oid IS NULL) AND o.object_id=? )
+ UNION
+ ( SELECT g.object_id, NULL, aclg.perm FROM vhffs_groups g INNER JOIN vhffs_object o ON g.gid=o.owner_gid INNER JOIN vhffs_acl aclg ON aclg.granted_oid=g.object_id WHERE aclg.target_oid=? )
+ ORDER BY name
' );
return undef unless $sth->execute( $object->get_oid, $object->get_oid, $object->get_oid );
return $sth->fetchall_arrayref({});