Score:0

How to find joins performed without indexes?

jp flag

I run a WordPress website on Mariadb 10.6, and recently I saw an error Joins performed without indexes in Mysqltuner.

Although the number is not very large, Mysqltuner recommends that you keep increasing the Key_buffer_size.

However, my VPS doesn't have a lot of free memory, so I'm solving this error with another issue.

Since I have about dozens of plugins active, I want to check which awesome plugin is causing the problem.

So, first of all, I enabled the error log as follows.

log-queries-not-using-indexes = 1
log_error = /var/log/mysql/mysql-error.log
slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 3

And after a certain period of time, I ran pt-query-digest to analyze the error log.

pt-query-digest /var/log/mysql/mysql-slow.log

But I can't figure out any other problems.

Among the many queries in the slow log, how can you determine which one is trying to join with a column without an index?

I don't know the database, so I can't figure it out just by looking at the query.

Score:0
jp flag

To FIND ONLY joins performed without indexes,

From MySQL Command Prompt, determine current values so you can return to normal after 1 hour of recording ONLY JPWI in your slow query log

SELECT @@long_query_time;
SELECT @@min_examined_row_limit;
      write down the above values

SET GLOBAL long_query_time=3600;  for a ONE MINUTE slow log trigger
SET GLOBAL min_examined_row_limit=1;   if the query reads one row, consider logging
SET GLOBAL log_queries_not_using_indexes=1;  to get the log you are needing

IN AN HOUR, SET GLOBAL long_query_time=discovered above; SET GLOBAL min_examined_row_limit=discovered above; SET GLOBAL log_queries_not_using_indexes=0; # to turn OFF feature

FLUSH LOGS;

go review your last hour of Slow Query Log for the queries involved with no indexes.

View profile for contact info, get in touch, if you need additional advice, please.

Most people DO NOT record slow queries and queries without indexes to avoid separating the spaghetti. GET ONE or the OTHER, only to retain some form of sanity.

Score:0
ua flag

Do you have MyISAM tables? If not (and your tables should be InnoDB), lower key_buffer_size to 30M.

"Joins without indexes" is not necessarily a problem. If you have slow queries, that is more important. See the SlowLog. That is, work on improving the slowest, whether or not they are "joins without indexes". Use pt-query-digest or mysqldumpslow -s t

For WordPress performance, add this plugin: WP Index Improvements

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.