Performance: Plugin database tables
This affects page load speed and server response time by influencing database query performance and data retrieval efficiency.
CREATE TABLE wp_plugin_data (id INT PRIMARY KEY, data TEXT, INDEX(data(10))); -- Plugin queries use indexed columns and cache results
CREATE TABLE wp_plugin_data (id INT, data TEXT);
-- Plugin runs many unindexed queries on this table for every page load| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Unindexed large plugin tables | N/A (server-side) | N/A | Delays initial paint by 200-500ms | [X] Bad |
| Indexed plugin tables with caching | N/A (server-side) | N/A | Reduces paint delay to under 100ms | [OK] Good |
| Large autoloaded options in wp_options | N/A (server-side) | N/A | Adds 100-300ms delay to first paint | [X] Bad |
| Non-autoloaded options or custom tables | N/A (server-side) | N/A | Speeds up first paint by avoiding unnecessary data load | [OK] Good |
myplugin_data?$table_name = $wpdb->prefix . 'myplugin_data'; $sql = "CREATE TABLE $table_name ( id mediumint(9) NOT NULL AUTO_INCREMENT, name varchar(100) NOT NULL, PRIMARY KEY (id) );"; dbDelta($sql);
$table_name = $wpdb->prefix . 'myplugin_data'; $sql = "CREATE TABLE $table_name ( id int NOT NULL AUTO_INCREMENT, name varchar(100) NOT NULL, PRIMARY KEY (id) )"; dbDelta($sql);
email varchar(255) NOT NULL to your plugin's custom table myplugin_data during an update. Which approach correctly updates the table without losing data?Pass the test and this pattern moves unknown