Support » Plugin: User Access Manager » UAM plugin – it calls so many single queries

  • innonirali

    (@innonirali)


    – Here i have given a link of image – for my one page – UAM plugin takes more than 800+ queries – where some are the queries which are called more several times for ex:

    SELECT * FROM wp_uam_accessgroups WHERE ID = 1

    SELECT * FROM wp_uam_accessgroups WHERE ID = 2 … and so on.

    So, cant we combine these queries into 1 by usin IN operator like –

    SELECT * FROM wp_uam_accessgroups WHERE ID IN (1,2,..)

    Same thing happens with following queries :

    SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate

    FROM wp_uam_accessgroup_to_object

    WHERE group_id = ‘7’

    AND group_type = ‘UserGroup’

    AND object_id != ”

    AND (general_object_type = ‘_post_’

    OR object_type = ‘_post_’)

    AND (from_date IS NULL

    OR from_date <= ‘2019-01-31 10:35:23’)

    AND (to_date IS NULL

    OR to_date >= ‘2019-01-31 10:35:23’)

    SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate

    FROM wp_uam_accessgroup_to_object

    WHERE group_id = ‘7’

    AND group_type = ‘UserGroup’

    AND object_id != ”

    AND (general_object_type = ‘_term_’

    OR object_type = ‘_term_’)

    AND (from_date IS NULL

    OR from_date <= ‘2019-01-31 10:35:23’)

    AND (to_date IS NULL

    OR to_date >= ‘2019-01-31 10:35:23’)

    SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate

    FROM wp_uam_accessgroup_to_object

    WHERE group_id = ‘1’

    AND group_type = ‘UserGroup’

    AND object_id != ”

    AND (general_object_type = ‘_role_’

    OR object_type = ‘_role_’)

    AND (from_date IS NULL

    OR from_date <= ‘2019-01-31 10:35:23’)

    AND (to_date IS NULL

    OR to_date >= ‘2019-01-31 10:35:23’)

    SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate

    FROM wp_uam_accessgroup_to_object

    WHERE group_id = ‘1’

    AND group_type = ‘UserGroup’

    AND object_id != ”

    AND (general_object_type = ‘_user_’

    OR object_type = ‘_user_’)

    AND (from_date IS NULL

    OR from_date <= ‘2019-01-31 10:35:23’)

    AND (to_date IS NULL

    OR to_date >= ‘2019-01-31 10:35:23’)

    And then there are number queries for all posts like:

    SELECT * FROM wp_posts WHERE ID = 1

    SELECT * FROM wp_posts WHERE ID = 2

    SELECT * FROM wp_posts WHERE ID = 3

    SELECT * FROM wp_posts WHERE ID = 100 …

    I have read your earlier comments that you are having very busy schedules – but if possible then can you please clear my confusion that why such big number of queries are called on single page load – on which parameters it depend on (i mean number of posts or number of access group created ).

    If i will get clear idea of requirements of queries then i can contribute to query optimization of the plugin.

    Thank you in advance.

    • This topic was modified 1 year ago by innonirali.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • @gm_alex – Can you please look once for my issue?

    Thanks in advance.

    Plugin Author GM_Alex

    (@gm_alex)

    Hey,

    sorry for the late response, the idea was to load only objects which are really needed. For example

    SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate
    FROM wp_uam_accessgroup_to_object
    WHERE group_id = ‘7’
    AND group_type = ‘UserGroup’
    AND object_id != ”
    AND (general_object_type = ‘_term_’ OR object_type = ‘_term_’)
    AND (from_date IS NULL OR from_date <= ‘2019-01-31 10:35:23’)
    AND (to_date IS NULL OR to_date >= ‘2019-01-31 10:35:23’)

    These queries aren’t that complex so that shouldn’t have a big impact imho.

    The SELECT * FROM wp_posts WHERE ID = 1 is, as far I can see, directly from WordPress, using the get_post function.

    Anyway you could fork the Github project and adjust it to your needs, if no tests will fail and nothing break I will merge it. A possible point for optimization could be the PostController::filterRawPosts function. Here you could load the posts all at once using get_posts instead of get_post. So you have to extend the WordPress wrapper class, the ObjectHandler with at function getPosts and then modify the filterRawPosts function. That could save some queries.

    • This reply was modified 11 months, 2 weeks ago by GM_Alex.
    • This reply was modified 11 months, 2 weeks ago by GM_Alex.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘UAM plugin – it calls so many single queries’ is closed to new replies.