• Resolved Marcus Fridholm

    (@marcusfridholm)


    I chose this plugin for an intranet I’m working on. It seemed simple and clear, and in general to be doing what I needed.

    I added the groups I needed, just short of 40, then categories to match them, and parent pages for each. Roughly 40 categories and top-level pages plus another 10 or so subpages.

    Since the groups aren’t hierarchical, a lot of pages and categories have more than group assigned to them, on average two.

    I now started adding posts to a couple of the categories, about 70 posts in all.

    While I was working the system got slower and slower, not so much in the admin area as in the front.

    So I installed debug objects to see wtf was going on. And noted that on the same page where I had 18 (eighteen) queries without UAM, i had 10302 (ten thousand threehundred and two queries I sh*t you not!) with the plugin active.

    Total query time: 1 392,1ms for 10302 queries (1,392127990722656s)
    Page generated in 4 000,0ms; (4,6721889972686767578125s); 65,20% PHP; 34,80% MySQL

    In reality that means going from a page served in less than half a second to about four seconds on localhost and eight seconds on my actual host. Activating W3 total cache, the time got down to seven seconds, so that is still faaaaar too slow.

    I sat down and started to analyze the reported queries, to try to get why the sh*t hit the fan that way, and it turns out it is probably an iteration/recursivity problem.

    That is, rather than doing a single query and using the result to filter what is accessible or not, it asks for each and every restrictable object. In some cases it makes the same query three or more times per object almost consecutively.

    Like this:

    Time: 0.2ms (0.00022101402282715s)
    Query: SELECT object_id as id
    FROM wp_uam_accessgroup_to_object
    WHERE group_id = 1
    AND object_type = ‘category’
    Function: UamUserGroup->getObjectsFromType()

    Time: 0.2ms (0.00017690658569336s)
    Query: SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = ‘category’ AND t.term_id = 1 LIMIT 1
    Function: get_term()

    Time: 0.2ms (0.00018811225891113s)
    Query: SELECT object_id as id
    FROM wp_uam_accessgroup_to_object
    WHERE group_id = 1
    AND object_type = ‘category’
    Function: UamUserGroup->_getAssignedObjects()

    Time: 0.1ms (0.00014400482177734s)
    Query: SELECT COUNT(*)
    FROM wp_term_relationships AS tr,
    wp_term_taxonomy AS tt
    WHERE tr.object_id = ‘247’
    AND tt.term_id = ‘1’
    AND tr.term_taxonomy_id = tt.term_taxonomy_id
    AND tt.taxonomy = ‘category’
    Function: UamUserGroup->_isPostInCategory()

    Time: 0.2ms (0.00021100044250488s)
    Query: SELECT object_id as id
    FROM wp_uam_accessgroup_to_object
    WHERE group_id = 1
    AND object_type = ‘post’
    Function: UamUserGroup->_getAssignedObjects()

    And so on… for ever and ever and ever.

    So my choices are to accept the performance hit, go through and debug the 4000 lines of code in the plugin, or start over with another plugin.

    Alternative one is probably a deal-breaker, since either the customer or the customers host will flog me if I let this go live in its current condition.

    Alternative two would be doable if I can be fairly sure of success. The cost would be time, which I can pay if it works and not if it doesn’t.

    The third alternative means starting over, which is very unappealing but might be what it comes down to in the end.

    What I would like is for the plugin author to test and see if he can recreate the problem, and share what might be the offending method, if there are any workarounds and whether it is a simple fix or means a total rewrite.

    If it is something he can recreate and if it is doable to fix it within a reasonable time-frame, I am available to help.

    http://wordpress.org/extend/plugins/user-access-manager/

Viewing 15 replies - 16 through 30 (of 83 total)
  • Handoko

    (@handoko-zhang)

    Any progress for improving the performance?

    I’m looking for a plugin for limiting read/write access of posts. I found 2 candidates: User Access Manager and WordPress Access Areas. Can anyone please test the WordPress Access Area plugin and tell me if it also have any performance issue?

    Author?

    Sorry for nagging, but we like your interface and wondering about comment for solving the speed issue/ hack from this topic?

    Plugin Author GM_Alex

    (@gm_alex)

    Hi,

    sorry about not giving feedback but at the moment I have a lot to do at work, if I have some free time I will try to fix it. Hopefully next week.

    Greetings,
    Alex

    Plugin Author GM_Alex

    (@gm_alex)

    Hi,

    today I found some time. Could all interested people please try the developer version which can be found here: User Access Manager dev version

    NOTE: This is non stable version, but you feedback will help me with this issue. Thanks!

    Greetings,
    Alex

    Hi, Great! Downloading and gonna setup a test dev install. Are there any notes about the changes?

    And BTW, We just finished (today) a sync fix between MailPress and UAM, and subscriptions to new post or categories that are restricted, will be filtered as well for accepted users only.

    So we are very exited if UAM speeding thing up.

    Thanks for your time o far…

    Thread Starter Marcus Fridholm

    (@marcusfridholm)

    I have a testing environment where I did my hacks, will try it there too see if the issues are solved.

    Getting back to you as soon as I have tried it.

    Thread Starter Marcus Fridholm

    (@marcusfridholm)

    I’ll have to try with at pristine install, but so far the problems with this version prevents useful testing.

    What I did was installing the dev-version on my local mirror of the site that caused troubles. Before I did so I dumped the old folder, to make sure there were no conflicting code. I also deleted the hack-function I used before (see earlier post).

    In the DB, there already was 39 groups. And among the pages and categories all these groups were in use. The thing that happened immediately was that all my data about access restrictions in the uam_accessgroups_to_object table was eradicated.

    Unless the most lax group, the one that all registered members get automatically was selected, there was no restrictions whatsoever. That is, no groups but group 1 could be assigned, and if group 1 was assigned, then all groups got assigned to the page/post/category.

    Needless to say. Testing whether the speed issues remains when all your restrictions get squashed isn’t exactly meaningful.

    As I said, I’ll try with at pristine install to see if there are any conflicts causing this, but for now I can’t give any meaningful feedback on the speed of your changes.

    Plugin Author GM_Alex

    (@gm_alex)

    @marcus: So if I got you right it dropped the content of your uam_accessgroups_to_object table? Could you provide me a dump of your data (I know I already asked) if you mask that with a simple mysql query?

    Thread Starter Marcus Fridholm

    (@marcusfridholm)

    I could provide you with the UAM table data, that is not any big secret.

    If you want anything else, please be more specific. I suppose i could filter out all the actual content…

    But then you’d need the tables as they were before stuff got dumped, so that you can see the effect.

    Plugin Author GM_Alex

    (@gm_alex)

    @marcus: I was talking again about the whole database but with masked data.

    Thread Starter Marcus Fridholm

    (@marcusfridholm)

    I see.

    You want it in your gmail?

    Plugin Author GM_Alex

    (@gm_alex)

    Yes please.

    Thread Starter Marcus Fridholm

    (@marcusfridholm)

    OK I sent it.

    I masked content and passwords.

    This is timely… I’ve just implemented a site and incorporated UAM.
    Page rendering is now exceeding 30 secs per page and each is reporting 15,000 queries !!!!!!! It is also very slow within the admin. Caching is no answer for me as the site is too dynamic. I needed to put this out live so I’m very keen to get this fixed even if only with a temporary hack.
    Any help… testing or code debug I’m happy to assist with… otherwise I’ll just watch with keen interest.

    Currently testing your last dev version, will let you know how it goes..

    Fail for me, I can create a group an assign it to a category but then if I create a second group it auto assign it to the category that I previously setup

    Lets say I have categoray SALES, and I create group A, so I assign group A to category SALES but as soon as I create group B it auto assign it to the category SALES

Viewing 15 replies - 16 through 30 (of 83 total)
  • The topic ‘Repeated queries and scalability’ is closed to new replies.