Slow Queries on Catalogsearch_query – How to Optimize

catalogsearchMySQLquerysearch

I have a site with approx 6500 products. The are constantly running into problems where they run up against the hosting companies PHP Process limit.

I have been running a SQL profiler against their site today and came up with the following slow queries:

SLOWEST: UPDATE catalogsearch_query SET is_processed = '0' (13s)

The next slow query is the actual search on the catalog search query table. (78,000 rows)

enter image description here

My question: Can I truncate this table?

Here are all the queries by threads during the day in order of slowness

enter image description here

Best Answer

That's the table responsible for the list of search queries made on your site. It can be truncated, but you lose all of the historical data.

I think there's another underlying problem here. 78K should only take a few milliseconds perform a SELECT. Even with a full-column select statement, as you are doing in the screenshot, it should be very quick.

Perhaps you have an extension or a program that works on this table? Or too many cron jobs? Try running SHOW PROCESSLIST; and see what kind of database operations are going on when it's slow.