Optimize WP_Query
Every time you run query_posts() or create a new WP_Query() (secondary loop), four queries are run:
- Getting the posts according to your query string
- Calculating how many posts exist for this query (to create pagination)
- Loading all metadata for the posts
- Loading all taxonomy term information for the posts
- It is possible to turn off queries 2-4 to increase performance, like this:
XX
$my_query = new WP_Query(array(
'no_found_rows' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false
));
Andrew Nacin: WP_Query / WordPress In-depth - summary and highlights - Useful Snippets
Dodavanje indexa na tabele kako bi se ubrzao rad sa tabelama u bazi
Nije mi samo jasno zašto u originalu, u core WP, ovo nije dodato? Ne razumem koje su loše posledice?
- Index WP MySQL For Speed | OllieJones/index-wp-mysql-for-speed, nekada davno sam ja ručno to radio a sada postoji ovaj odličan plugin:
- Vevida Optimizer | vlastuin/vevida-optimizer
Originalni članak koji do detalja objašnjava šta ovaj prvi plugin menja i zašto: Adding high-performance keys to MySQL tables to speed up WordPress and Speeding up WordPress database operations
More articles:
- Add MySQL Index to WordPress wp_options Table •
- WordPress Database Optimization Requires Indexes for Custom Tables | SpinupWP
Optimize Wordpress DB
WordPress wp_options table autoload micro-optimization - Sysadmins of the North
Add index to
ALTER TABLE wp_options ADD INDEX (`autoload`);
Add MySQL Indexes for WordPress Sites #24044 (Add index to wp_options to aid/improve performance) – WordPress Trac performance - Slow Query for the wp_options table - WordPress Development Stack Exchange
Convert MySQL MyISAM tables to InnoDB
Use WP_ALLOW_REPAIR to Repair the WordPress Database
Fix A Corrupted WordPress Database To fix the database connection error, you should log into your FTP client and go to the root WordPress folder. Then, edit the wp-config file there, by adding the following code and saving your file.
define("WP_ALLOW_REPAIR", true);
Once done, go to /wp-admin/maint/repair.php
How To Repair the WordPress Database via WP-CLI
If you’re using the command line to access your WordPress installation, you can use WP-CLI to repair the database.
To do this, use the wp db repair
command. This can be the quickest way to repair the database.