WordPress Developer Ukraine, Kyiv
Use MySQL Window Functions and CTEs for WordPress Analytics Queries

Use MySQL Window Functions and CTEs for WordPress Analytics Queries

MySQL window functions and CTEs for WordPress reports An editorial report often asks questions like “the top three posts of each category” or “the running total of comments per month”. With plain GROUP BY such questions need several queries and PHP loops. Window functions (ROW_NUMBER(), RANK(), SUM() OVER) and common table expressions (WITH) answer them…
Implement Full-Text Search in WordPress with MySQL MATCH AGAINST

Implement Full-Text Search in WordPress with MySQL MATCH AGAINST

Full-text search in WordPress with MySQL MATCH AGAINST The built-in WordPress search runs LIKE '%word%' on the title, excerpt and content of every post. That reads the whole table for each search and sorts the results only roughly by relevance. On a site with tens of thousands of posts, a MySQL FULLTEXT index answers the…
Optimize WordPress Database Tables with ANALYZE, OPTIMIZE, and Slow Query Log

Optimize WordPress Database Tables with ANALYZE, OPTIMIZE, and Slow Quer ...

Optimize WordPress database tables: cleanup, ANALYZE and OPTIMIZE Over the years a WordPress database collects revisions, expired transients, trashed posts and orphaned meta rows, and the large tables (wp_posts, wp_postmeta, wp_options) get fragmented. The MySQL optimizer also works with index statistics that can be outdated after big imports or deletions. Three commands help: ANALYZE TABLE…
Run Custom SQL Queries in WordPress with $wpdb->prepare and get_results

Run Custom SQL Queries in WordPress with $wpdb->prepare and get_results

Run custom SQL queries in WordPress with $wpdb->prepare() and get_results() WP_Query covers most needs, but some queries it cannot express or makes inefficient: aggregations with GROUP BY, joins across several tables, bulk updates. For those, WordPress gives the $wpdb object, a direct connection to the database, with $wpdb->prepare() for safe parameters.
Create a Custom Database Table in a WordPress Plugin with dbDelta

Create a Custom Database Table in a WordPress Plugin with dbDelta

Create a custom database table in a WordPress plugin with dbDelta wp_postmeta stores any key-value data, but for high-volume or relational plugin data (logs, statistics, bookings) it becomes a bottleneck: every value is a LONGTEXT in one huge table, and filtering by several values means several joins. A custom table gives you your own columns…