OrientDB 1.7.8: count(*) includes every record in a ORestricted derived class, even those that the user cannot read
It seems that OrientDB does not apply permission filter on records when a count(*) is performed if no where clause is supplied. As the matter of fact as workaround we use a fake where clause like 1=1 or just true, but it is very slow, I suppose because a scan is performed. So, given a class myClass that extends ORestricted:
select count(*) from myClass
returns the total number of records belonging to myClass even for the "reader" user.
select count(*) from myClass where true
returns the correct number of records that the "reader" user can read
Hi @laa, I saw your patch. If I have understood, the optimisation for the count function will not be applied if it is executed on a collection that extends ORestricted. I understand why: in this way the engine has to scan the entire collection to check if the current user has the read permission on every record and then count it. However I think that the optimisation could still be applied in case the user belongs to a role that has the database.bypassRestricted attribute. In this way administrators can perform count(*) queries very fast.
WDYT?
Hi, I agree with you )). Will fix it soon )).
On Thu, Oct 9, 2014 at 9:25 PM, giastfader [email protected] wrote:
Hi @laa https://github.com/laa, I saw your patch. If I have understood, the optimisation for the count function will not be applied if it is executed on a collection that extends ORestricted. I understand why: in this way the engine has to scan the entire collection to check if the current user has the read permission on every record and then count it. However I think that the optimisation could still be applied in case the user belongs to a role that has the database.bypassRestricted attribute. In this way administrators can perform count(*) queries very fast.
WDYT?
— Reply to this email directly or view it on GitHub https://github.com/orientechnologies/orientdb/issues/2859#issuecomment-58554582 .
Best regards, Andrey Lomakin.
Orient Technologies the Company behind OrientDB