Paginating Full-Text Results
Paginate full-text results with LIMIT/OFFSET. For large result sets, consider caching total counts since COUNT(*) with MATCH can be slow.
Paginate full-text results with LIMIT/OFFSET. For large result sets, consider caching total counts since COUNT(*) with MATCH can be slow.
-- Page 2 (10 results per page)
SELECT id, title,
MATCH(title, body) AGAINST('mysql') AS score
FROM articles
WHERE MATCH(title, body) AGAINST('mysql')
ORDER BY score DESC
LIMIT 10 OFFSET 10;
-- Count (can be expensive on large tables)
SELECT COUNT(*) FROM articles
WHERE MATCH(title, body) AGAINST('mysql');
Cache total counts for full-text searches — recomputing on every page is expensive.