• Resolved Tyler Tork

    (@tylertork)


    Doing performance testing with Query Monitor, I noticed the following queries originating from your plugin during load of a page:

    SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
    FROM wp_jjnk95_posts
    WHERE post_type = 'attachment'
    ORDER BY post_date DESC	
    
        wp_enqueue_media()
    
    	Plugin: real-media-library-lite 	3 	0.0066
    45	SELECT COUNT(*)
    FROM wp_jjnk95_realmedialibrary
    WHERE parent > -1	
    
        MatthiasWeb\R\v\Lang->getItems()
    
    	Plugin: real-media-library-lite 	1 	0.0014
    46	SELECT option_value
    FROM wp_jjnk95_options
    WHERE option_name = 'real_utils-transients'
    LIMIT 1

    These seem unnecessary overhead during a page rendering, and likely to add significantly to the page load time in cases where the media library contains a lot of images. What possible reason can there be to pull a list of all media created in the current month? Your plugin has no legitimate role in page rendering and should not be performing any operations in this context.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Matthias Günter

    (@mguenter)

    Hey @tylertork !

    Thanks for your message 🙂

    This SQL query is performed through this function: https://developer.wordpress.org/reference/functions/wp_enqueue_media/

    This is needed to make the folder management available to a lot of page builders. Real Media Library itself is never rendered/executed to users without the upload_files capability. But you can try this: Settings > Media > Uncheck “Load RML on frontend”.

    Regards 😊

    Thread Starter Tyler Tork

    (@tylertork)

    A visitor viewing a page or post, even if they are logged in, is viewing the post, not editing, and doesn’t need the upload_files capability initialized. This is unnecessary overhead. Surely your plugin can detect whether it’s being invoked as part of a post view (as opposed to edit) and exit with a minimum of CPU and database usage?

    Plugin Contributor Matthias Günter

    (@mguenter)

    Hey @tylertork !

    Thanks for your follow-up.

    Yeah, Real Media Library loads its assets for all sites when the current user has the upload_files capability. This makes sure, that Real Media Library works with all page builder (e.g. Visual Composer does edit in the “view context” of a page).

    If you deactivate “Laod RML on frontend”, the assets are only loaded on admin pages (wp-admin).

    Regards
    Matthew 😊

    Thread Starter Tyler Tork

    (@tylertork)

    noted

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Unnecessary queries during page load’ is closed to new replies.