1

Does anyone know if there's an inherent problem with an extremely large permissions table? I'm dealing with a Drupal install with about 50 roles (permissions were set up using taxonomy terms), and there look to be about 800 permissions. So, quick estimates suggests approximately 40000 checkboxes on the permission table. Now, out of all of these, probably only about .1% are actually checked; I know that the role_permissions table only stores the enabled permissions. I don't know how Drupal is checking the permissions though as it goes; obviously, if it were making DB calls for each checkbox to check its status, that would be horrible.

Obviously, this can't be a good thing, but can someone tell me if it's necessarily a bad thing? The connection seems to be timing out before table gets loaded (or at least I think it's timing out; this is my first time using IIS with Drupal, and it's error message is vague, to say the least.) Does anyone have any suggestions beyond "remove unnecessary roles"? (Not that it's a bad suggestion, and I'll probably end up having to recommend it anyway, I'm just looking for additional options.)

1

No, Drupal isn't making a single DB call per checkbox - that would be suicide :)

Looking at user_role_permissions() should de-mystify the whole thing...all enabled permissions for the given roles (or all roles if none are provided), are lazy-loaded into memory when they're needed, and statically cached for the same request.

It's about as efficient as it can possibly be when you consider how Drupal's permission system works - I doubt you'll be able to squeeze anything more out of it that wouldn't be considered pointless micro-optimising.

As an aside 50 roles is a lot. I've never seen a site with anywhere near that many; if you can reduce the number of those, you'll be doing yourself a great service.

| improve this answer | |
  • Sorry, I was either more ambiguous than I meant, or I'm missing something. I totally get what you're saying about when it checks for permissions for particular content/etc., but I mean when it's loading the actual permissions table itself, for the user/admin to edit. – UnsettlingTrend Jun 19 '14 at 12:59
  • Same deal - all loaded in one SQL query and stored in memory. So memory becomes your finite resource at that point - if you haven't got enough, get more! – Clive Jun 19 '14 at 13:00
  • 1
    Heh, the server I'm on started having [more of] these timeouts AFTER they increased the memory to it; I need to figure out what else might be causing it. It's around 50 because they initially set it up so that the roles more or less mimicked the taxonomy terms. Then the terms could be used for access control. Trust me though, you don't need to sell me on limiting that. ;-) Thanks! – UnsettlingTrend Jun 19 '14 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.