• d5dhatch

    (@d5dhatch)


    I created 3 new custom fields using this plugin. I noticed that the plugin is adding 20 new queries when I load my gallery page. I’m not a coder but that seems like too many. Is this normal? Below I’ve pasted some debug output for 3 of those queries and the other 17 are similar

    # Time: 0.00044083595275879
    Query: SELECT vals.*, cols.field_name, cols.id AS field_id, cols.field_type FROM wp_v1s1oj_nggcf_field_values AS vals LEFT JOIN wp_v1s1oj_nggcf_fields AS cols ON vals.fid = cols.id WHERE vals.pid = '1' AND cols.ngg_type = '1'
    Call from: require, require_once, include, the_content, apply_filters, call_user_func_array, do_shortcode, preg_replace_callback, do_shortcode_tag, call_user_func, NextGEN_shortcodes->show_gallery, nggShowGallery, nggCreateGallery, apply_filters, call_user_func_array, nggcf_image_obj, nggcf_hold_field_values
    # Time: 0.00049304962158203
    Query: SELECT vals.*, cols.field_name, cols.id AS field_id, cols.field_type FROM wp_v1s1oj_nggcf_field_values AS vals LEFT JOIN wp_v1s1oj_nggcf_fields AS cols ON vals.fid = cols.id WHERE vals.pid = '2' AND cols.ngg_type = '1'
    Call from: require, require_once, include, the_content, apply_filters, call_user_func_array, do_shortcode, preg_replace_callback, do_shortcode_tag, call_user_func, NextGEN_shortcodes->show_gallery, nggShowGallery, nggCreateGallery, apply_filters, call_user_func_array, nggcf_image_obj, nggcf_hold_field_values
    # Time: 0.0005340576171875
    Query: SELECT vals.*, cols.field_name, cols.id AS field_id, cols.field_type FROM wp_v1s1oj_nggcf_field_values AS vals LEFT JOIN wp_v1s1oj_nggcf_fields AS cols ON vals.fid = cols.id WHERE vals.pid = '3' AND cols.ngg_type = '1'
    Call from: require, require_once, include, the_content, apply_filters, call_user_func_array, do_shortcode, preg_replace_callback, do_shortcode_tag, call_user_func, NextGEN_shortcodes->show_gallery, nggShowGallery, nggCreateGallery, apply_filters, call_user_func_array, nggcf_image_obj, nggcf_hold_field_values

Viewing 3 replies - 1 through 3 (of 3 total)
  • shauno

    (@shauno)

    Short answer: Because writing plugins for wordpress is a giant pain in the ass.

    Slightly longer (but just as incoherent answer): This plugin was originally written for a friend. A favor for them, because I’m a nice guy that way 🙂
    Being such a nice guy, I decided to release it, for free, to the entire world (I don’t even expect revere and admiration from the unwashed masses).

    It was written for a very simple purpose, but has evolved into what it is now, including a bunch of features requested by the community (again, added free of charge).

    Professional software is NOT written this way. Professional software goes through a bunch of bureaucracy and red tape to change the simplest things. Lots of (very well paid) people look at things like usability, accessibility, and how to implement everything using the very best coding techniques and technologies. Questions like “Is it better to sacrifice a little more memory to use a little less processor in iterations over X?”, “How would that affect situation Y?” are asked. They are then tested, and benchmarked. Then people in suits make misinformed decisions based on their perception of the results of these tests.

    So, to summarize: It queries so much, ’cause it can. The longest query pasted above took 0.0005 seconds. That’s about half a one thousandth of a second. *blink*

    Yours in free stuff
    Shauno

    PS, the plugin is licensed as GPL (you did read the license hey?). That means you can look at the source, and make it more awesomer! You could then release those changes to the world, and become part of the covenant of free wordpress stuff coders!

    Thread Starter d5dhatch

    (@d5dhatch)

    Thanks Shauno,
    I appreciate the plugin, its going to let me do some things I otherwise couldn’t. I’ve been extra query-conscious lately after inadvertently creating a set of pages that needed over 350 queries to display itself and hence was slower than I wanted them to be.
    Thanks for the explanation.

    David

    shauno

    (@shauno)

    Hey David
    Thanks for taking that in the spirit it was intended. I needed to get my (somewhat) sarcastic rant over for the day 🙂

    If you really are trying to lose some query weight, have a look at the functions nggcf_hold_field_values() and nggcf_hold_gallery_field_values

    The plugin already does try limit its queries by storing all custom fields per image/gallery per request. So if you have 2 custom fields for 1 image, and try display them both there should only be 1 query to do that.

    The logic for this was essentially a middle ground between being a memory hog (storing too much info that might not be used), or being fast and loose with the queries.

    If you do decide to optimise it, let me know. I would be happy to include it in the next release.

    Shauno

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

The topic ‘[Plugin: NextGEN Custom Fields] Why does this plugin generate so many queries?’ is closed to new replies.