My co-worker, Matthew Avalos, rewrote the acs_permission.permission_p package.
Here is his email to me:
---
It looks like the permissions data model isn't completely dead. At least the question, "Does party A have permission P on object O?"
I rewrote acs_permission.permission_p and got rid of the unions. That didn't help at all performance wise, but it did allow me to rewrite the selects invidually, and after a while it was clear that only the first select was the hog. I rewrote the first one using oracle exist, and that fixed it. I guess the exist short circuts the huge selects like you would expect. I did the same for the other 4 selects in the union for good measure.
btw, I'm not sure I know what some of those selects are doing, especially the one that puts a 0 in the party column.
----
I put the file on http://jongriffin.com/static/openacs/permissions/ for public scrutiny.
If anyone else would like to check it out please feel free to do so. I will commit this into OpenACS in a few days to give it a little testing period.