• Resolved Trebly

    (@trebly)


    Hi,

    I am using 10.2.6.8 version.
    I have done some little changes commented here some month ago (note 1)

    Today, as I test for exploitation, I meet a great problem of performances and I need help to find how to reduce DB accesses and time execution on server.
    the USE of UAM currently have effect :

    • on requests to database : to deliver a single post, database queries jump from 130 to 680
    • on execution time on database : from 0.4s to 2.8s
    • on whole deliver time : from 7s to 18s

    Many doubled requests appear.

    When I uses UAM combined with W4 post list (to produce post lists), I reached most of time the timeout and an overload of server resources.

    I have compared with or without activation, various parameters, post attachment to groups etc..
    I have not found any valuable solution.
    I don’t think that this can be linked with my light modifications.

    I got some reductions : When associating a post to groups, if the user have in mind the hierarchy induced by roles it can reduce the groups checked for example reduce from five to one will reduce overall 25% time execution (requests on groups)

    So, do you have recommendations to manage resources when UAM is used ?

    Best regards

    Trebly
    _____________________________________________________________
    note 1 : to manage access to visitors independently of the wp publish core options = visitor is not a defined user… with this feature, even though a post is published, a visitor cannot have access to element if UAM-visitor group is not attached to the element by the author, or admin or… Then it is possible to see for anybody how appears exactly a document inserted into the whole site. Just check the UAM-visitor group for the element will set the document visible to visitor (and to all others) regardless other groups attached.
    This feature functions with post and, very important, menu options.

    • This topic was modified 7 years, 11 months ago by Trebly.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Trebly

    (@trebly)

    Hi,

    I sought for finding node of the problem, here is joined my report :

    This is the algorithm of the widget-categories, it is the way for walking through the tree which generates the problem.
    Each node is got separately and issues a UAM request for validation of access (192 accesses and 80% of resources of the whole of the post display).

    Nevertheless there are sometimes other UAM internal loops which could avoid to call directly a request to the DB, so a solution is : before loop issue a more global request to create an array into which data could be found.

    But they are inside the 10% of problems remaining.

    Best regards

    Trebly
    _________________________________________________________
    Report which shows to origin of the overload of resources

    debug-from-logs-b61206-1-notes-2-UAM_queries

    ________________________________ Query type ______________________
    Repeated 192 times on various wp_term_relationships.term_taxonomy_id IN (111)
    IN (…) various selections
    elementary request is between 0.003 average near 0.015s

    the whole uses :
    Queries in filter (UAM && WP_Query->get_posts()
    wp-includes/query.php:3655 : 192 2,3712
    Queries in filter (UAM All) : 512 2,7610

    on Total Queries for page : 671 2,9845

    The Widget : categories is the origin of 80% of time used
    wp_dropdown_categories()
    wp-includes/category-template.php:416
    WP_Widget_Categories->widget()
    wp-includes/widgets/class-wp-widget-categories.php:83

    It is 80% of the problem of DB resource used by UAM
    repeated selection for drop-down widget of the categories
    _________________________________________________________
    SELECT wp_posts.*
    FROM wp_posts
    LEFT JOIN wp_term_relationships
    ON (wp_posts.ID = wp_term_relationships.object_id)
    WHERE 1=1
    AND ( wp_term_relationships.term_taxonomy_id IN (111) )
    AND wp_posts.post_type = ‘post’
    AND ((wp_posts.post_status = ‘publish’))
    GROUP BY wp_posts.ID
    ORDER BY wp_posts.post_date DESC

    The call stack of this request is :
    __________________
    WP_Query->get_posts()
    wp-includes/query.php:3655
    WP_Query->query()
    wp-includes/query.php:4050
    get_posts()
    wp-includes/post.php:1595
    UserAccessManager->_getTerm()
    wp-content/plugins/user-access-manager/class/UserAccessManager.class.php:1856
    UserAccessManager->showTerms()
    wp-content/plugins/user-access-manager/class/UserAccessManager.class.php:1921
    apply_filters(‘get_terms’)
    wp-includes/plugin.php:235
    get_terms()
    wp-includes/taxonomy.php:1235
    wp_dropdown_categories()
    wp-includes/category-template.php:416
    WP_Widget_Categories->widget()
    wp-includes/widgets/class-wp-widget-categories.php:83
    WP_Widget->display_callback()
    wp-includes/class-wp-widget.php:377
    dynamic_sidebar(‘sidebar-1’)
    wp-includes/widgets.php:738
    load_template(‘~/wp-content/themes/Twentythirteen2/sidebar-main.php’)
    wp-includes/template.php:572
    locate_template()
    wp-includes/template.php:531
    get_sidebar(‘main’)
    wp-includes/general-template.php:122
    load_template(‘~/wp-content/themes/Twentythirteen2/footer.php’)
    wp-includes/template.php:572
    locate_template()
    wp-includes/template.php:531
    get_footer()
    wp-includes/general-template.php:84

    Thread Starter Trebly

    (@trebly)

    Hi,

    Complements :

    When UAM is not running there are no more requests to database.

    So it seems that the problem is that when the basic function of WP : “wp_dropdown_categories” is called, at each node when attached posts are accessed the UAM hook checks the access group launching the db query above (previous comment).
    When this is done by the core there is no significant access to database, but when UAM is used each node leads to an heavy query (average of 3 per node it seems).

    I think that it should be necessary for categories and others list produced to have a global query for visibility and a comparison of array or objects to answer for access.
    I have no idea how to perform this but for now I cannot display such list of objects when I use UAM.

    May be other widget for categories, using ajax, will be less voracious in resources.

    Best regards

    Trebly

    Plugin Author GM_Alex

    (@gm_alex)

    You could try the newst version at https://github.com/GM-Alex/user-access-manager

    Feedback would be great.

    Notes

    • The object type ‘category’ at the uam_accessgroup_to_object table will change to ‘term’. So you need to update the database if you want to use the test version and change it back if you are done with testing.
    Plugin Author GM_Alex

    (@gm_alex)

    Should be better with the latest version.

    Thread Starter Trebly

    (@trebly)

    Hi,

    Partial test (no statistics comparison) done today : everything OK, there are no more excessive resources used.

    Thanks

    Best regards

    Trebly

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Performance problems’ is closed to new replies.