• Resolved mb00

    (@mb00)


    Currently plugin performs SHOW TABLES LIKE ... on every page load, which is a slow and inefficient compared to simple SELECT query by calling createTable() method from createDBTables() in DBTable class.

    The better approach would be to introduce a database versioning system. Here is a simple example: https://gist.github.com/kurtpayne/2151282. You could probably implement it inside createDBTables() method leaving your existing createTable() method as is.

    Now, on each page request plugin will still call get_option(‘your_db_version_str’) and that’s fine because we can give instructions to autoload this option when user activates the plugin, and set the autoload flag to ‘no’ when plugin is deactivated. Here is WordPress blog post explaining option function improvements with an example: https://make.wordpress.org/core/2023/10/17/new-option-functions-in-6-4/#new-functions-to-set-option-autoload-values

    PS: if you intend to support older WordPress versions, you will have to wrap wp_set_options_autoload() or any other new functions in function_exists().

Viewing 1 replies (of 1 total)
  • Hi,

    Thank you for the useful information.

    We’ll make sure to pass this along to our development team.

    Thanks
    Flycart Team

Viewing 1 replies (of 1 total)

The topic ‘Database setup / DBTable improvements’ is closed to new replies.