How to Speed Up WordPress Search on a VPS with a Full-Text Index

WordPress search feels fine when a site is small. A visitor types a word, results appear, and nobody thinks about the database. That changes as the post count grows. On a VPS with a few thousand posts, the same search can take seconds or return poor matches. If you want to speed up WordPress search without buying a bigger server or installing a heavy search plugin, a MySQL full-text index is one of the most direct fixes available.

This guide covers the change on a self-managed VPS: why default search slows down, what a full-text index does, and how to add one and make WordPress use it.

Why You Need to Speed Up WordPress Search on a VPS

WordPress stores posts in wp_posts. Its default search runs LIKE '%term%' against the title and content, a pattern no normal B-tree index can serve, because the wildcard sits at the start of the term. MySQL must scan every published post instead, so on a large site that scan gets long and a slow search holds a connection while other queries wait.

That is why a site can feel fast on normal pages and slow only when someone uses search. Before you add an index, first learn how to clean up WordPress revisions and transients that slow down your site: a smaller table builds a smaller index.

How WordPress Search Works by Default

When a visitor searches, WordPress looks for each term in post_title and post_content, splitting the phrase into words and joining them with AND or OR logic. Each word adds another LIKE condition, so a three-word search can mean six pattern scans across the table.

This design has three limits: no ranking, so a passing mention can outrank a title match; no word stemming, so “backup” will not match “backups” reliably; and it scans instead of seeking, so the work grows with every post. A full-text index fixes the third limit, and helps with the first, because MySQL returns a relevance score for each match.

What a Full-Text Index Does Differently

A full-text index is a separate structure MySQL builds from the words in a column. Instead of reading every row, MySQL looks the word up in the index and jumps straight to matching rows, like checking the index at the back of a book instead of reading the whole book. For a WordPress search slow fix, that is the core change: replace a scan with a lookup.

MySQL supports full-text indexes on InnoDB, the engine WordPress uses by default. Index post_title and post_content together, in natural language mode, which ranks by relevance. One limit matters: MySQL ignores very short words, with a minimum length of three or four characters depending on the version, so decide on a fallback for short terms before you go live.

Before You Start: Back Up and Check Your Tables

Do not add an index to a live database without a backup. On a large wp_posts table the build takes time and can slow writes on older MySQL versions, so run it on staging first, or during a quiet period, and keep a restore point you have tested.

Back up with WP-CLI or mysqldump, then check the table size and published post count. If the table is far larger than the content you publish, first work through how to reduce WordPress database size without losing content. Full-text indexes need InnoDB in MySQL 5.6+ or MariaDB 10.0.5+; if your table still uses MyISAM, convert it on staging first.

Step 1: Check Your MySQL Version and Table Engine

Log in to MySQL and run these checks, replacing wp_posts with your table prefix if it differs.

SELECT VERSION();
SHOW TABLE STATUS LIKE 'wp_posts';
SELECT COUNT(*) FROM wp_posts WHERE post_status = 'publish' AND post_type = 'post';

Those three queries give you the version, engine, table size, and published post count. Also check the slow query log; if you have not turned it on yet, read how to find and fix slow queries with the MySQL slow query log first. It shows whether search is really the slow query on your site.

Step 2: Add a Full-Text Index to wp_posts

The mysql fulltext index wordpress setup starts with one statement. Run it on staging first, and time it, so you know how long the live build will take.

ALTER TABLE wp_posts ADD FULLTEXT INDEX ft_title_content (post_title, post_content);

On a large table this can take minutes, so do not stop it halfway. After the build, confirm it with SHOW INDEX FROM wp_posts WHERE Index_type = 'FULLTEXT';. You should see the new index with both columns. If it is missing, check the MySQL error log for a column type that does not support full-text indexing, or a table still on MyISAM.

Step 3: Rewrite the Search Query to Use MATCH AGAINST

WordPress does not use a full-text index on its own. Add a small plugin or a snippet in a child theme, hooked into posts_search or posts_clauses, that replaces the LIKE search with a MATCH ... AGAINST query. Do not edit core files; an update will wipe the change. This wp_posts search optimization only works when the query and the index match, so keep the column list identical.

SELECT ID, post_title,
  MATCH (post_title, post_content)
  AGAINST ('backup plugin' IN NATURAL LANGUAGE MODE) AS relevance
FROM wp_posts
WHERE MATCH (post_title, post_content)
  AGAINST ('backup plugin' IN NATURAL LANGUAGE MODE)
  AND post_status = 'publish' AND post_type = 'post'
ORDER BY relevance DESC;

When you write the WordPress version, sanitize the search terms and keep the filters for post status, post type, and password-protected posts: a search that leaks drafts is worse than a slow search. Test with a term in a title, a term only in the body, and a term that appears nowhere. Keep a fallback for short words, since MySQL returns no rows below the minimum length; fall back to the default LIKE search or show a message that the term is too short.

Step 4: Test the New Search and Measure the Difference

Test on staging with production data. Run the same searches before and after, and compare the result lists, not just the speed. A post with the term in its title should rank above one that mentions it once near the end of a long article.

Use EXPLAIN on the new query and look for the full-text index in the plan. If it still shows a full table scan, run ANALYZE TABLE wp_posts; and test again, then test under load by running several searches in a row while watching CPU and disk I/O.

What to Do When Search Is Still Slow

If search is still slow, check in order: confirm the index is actually used, as above; check the minimum word length and stopword settings, since a wrong setting can make common terms return no results; and check whether the query still joins other tables or runs extra meta queries from a plugin, which can undo the benefit of the index.

Fourth, look at the server: a VPS with too little memory for its database will read from disk on every query, index or not, so check the InnoDB buffer pool against the available RAM. For the admin side of the same problem, see how to speed up WordPress admin when the dashboard feels slow.

Finally, check postmeta. Search itself does not query it, but many themes and plugins add meta queries to search results, and a bloated postmeta table slows those down. If that is your case, work through WordPress database optimization and how to clean wp_postmeta bloat next. A full-text index fixes the search query, not every query around it, so fix the search query first, then the queries around it. That is how you speed up WordPress search and keep it fast.

When a Full-Text Index Is Not Enough

A MySQL full-text index has a ceiling. If your site holds tens of thousands of long posts, if visitors search in several languages, or if you need typo tolerance and synonym handling, a dedicated search engine will serve you better. It runs as a separate service, but it adds maintenance and a new failure point, so move to it only when the full-text index no longer meets the need.

For most blogs, documentation sites, and small stores on a VPS, the full-text index is enough: it uses the database you already run, needs no extra service, and turns search from a scan into a lookup. Add the index, change the query, test the results, and keep the fallback for short terms. Then watch the slow query log for a week; if search stops appearing there, the fix worked.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.