Slow performing queries called by metabox\c\api::create()

Support MB Custom Table Slow performing queries called by metabox\c\api::create()Resolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #31862
    sac@stupidcat.com[email protected]
    Participant

    I stumbled across something interesting as we are trying to improve performance and page load speed on one of our sites that use the Metabox AIO plugin. We have a custom post type with a field group, our field group is set to save to a custom table. We started implementing our field groups in custom tables as it is stated that custom tables perform better than the regular post meta table. However when inspecting the front end of our site to see if we have any slow queries running with a plugin called Query Monitor I have numerous slow queries being called by MetaBox\C\API::create() and altering tables. This happens on all pages site wide even admin pages and seems to be inconsistent between page loads - sometimes MetaBox\C\API::create() is attempting to alter multiple columns in a table and sometimes it is only trying to alter a few.

    These queries sometimes account for a whole second in the page load speed.

    As we strive forward in enhancing our site's performance, we were wondering if you could provide any insight on this and if it is all that necessary for these queries to be happening where tables/columns are being altered.

    #31878
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thank you for your feedback.

    I've escalated this issue to the development team to fix it in future updates.

    #31882
    Anh TranAnh Tran
    Keymaster

    Hi,

    Thanks for your message. This is a known issue and is not a bug. Meta Box needs a way to detect if the table exists and create a table if not. Internally, Meta Box uses the dbDelta function which does the job. This function causes the issue that you see.

    To eliminate this issue, a simple way is that you run the code to create a custom table only once. When the table is created, you can remove that code from your theme/plugin. The plugin will work well as the table is existing and match the fields.

    Alternatively, you can create the table manually (via SQL) and remove the code to create custom table in your theme/plugin.

    #39610
    komozuro@gmail.com[email protected]
    Participant

    To eliminate this issue, a simple way is that you run the code to create a custom table only once. When the table is created, you can remove that code from your theme/plugin. The plugin will work well as the table is existing and match the fields.

    I got exactly the same problem. Could you show this solution in detailed?
    Thanks

    #39638
    PeterPeter
    Moderator

    Hello,

    If you are using the builder, please disable the option "Create table automatically" after reloading a page. That means the table is created, no need to enable that option.
    Screenshot: https://monosnap.com/file/0wTw2K7nnwTCE3KJQ3qhF78rJQjUpk

    If you are using the code, please delete the code that creates the custom table after reloading a page. Please see here https://docs.metabox.io/extensions/mb-custom-table/#creating-a-custom-table

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.