I''m working on file upload/management app. users can specify one of the following read permission for any given folder : - parent (get permission from parent folder) - anonymous - only members - only members with specified roles Each file or folder object has_one permission object. The permission object acts_as_tree this works well reasonably well but there are two major performance issues I''m worried about : 1) long paths can result in a lot of hits on the db e.g. in a pth which is 8 folders deep with each folder getting permissions from the parent, getting a permission for folder 8 means 8 queries! 2) tryingto maintain any sort of integrity on the permissions can be a headache. If the permission on a folder gets changed, _all_ it''s sub-folders need to be checked for a clash e.g. a members only folder can''t have an anonymous sub-folder I tried and failed to implement a preorder tree traversal method. If i want to get that dirty I''ll go back to php! I''m just looking for a fresh perspective on the situation really. Any techniques for dealing with hierarchical data which might help? is it even worth trying to maintain integrity? permissions will be checked on each read of the folder anyway so does it matter if they''re not compatible with parent/child folders? alan
Maybe using the acts_as_nested_set and select the whole "chain" of folders upstream in one go (since you need them anyway, it seems?) You can also try to use triggers if you are running on PgSQL to grab the default permissions automatically if they are not set on select. On 8-apr-05, at 14:26, Alan Bullock wrote:> I''m working on file upload/management app. > > 1) long paths can result in a lot of hits on the db e.g. in a pth > which is 8 folders deep with each folder getting permissions from the > parent, getting a permission for folder 8 means 8 queries! > 2) tryingto maintain any sort of integrity on the permissions can be a > headache. If the permission on a folder gets changed, _all_ it''s > sub-folders need to be checked for a clash e.g. a members only folder > can''t have an anonymous sub-folder> I''m just looking for a fresh perspective on the situation really. Any > techniques for dealing with hierarchical data which might help? is it > even worth trying to maintain integrity? permissions will be checked > on each read of the folder anyway so does it matter if they''re not > compatible with parent/child folders?-- Julian "Julik" Tarkhanov