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

  • Creator
  • #31862

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
  • #31878
    Long Nguyen


    Thank you for your feedback.

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

    Anh Tran


    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.

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