show variables;
-- set SESSION sort_buffer_size= 524288
-- select 512*1024 (256 262144)
mysqldumpslow — Summarize Slow Query Log Files
SHOW VARIABLES LIKE '%log%';
SET GLOBAL slow_query_log = 'ON';
[mysqld]
# Set Slow Query Log
long_query_time = 1
slow_query_log = 1
slow_query_log_file = /usr/log/slowquery.log
log_queries_not_using_indexes = 1
#Set General Log
general_log = on
general_log_file=/usr/log/general.log
----------------------
If you use USE INDEX then you RECOMMEND optimizer to use this index, but it can use a table scan if optimizer thinks it will be faster. If you use FORCE INDEX then you MAKE optimizer to use this index even if it thinks a table scan is more efficient. Optimizer will use a table scan only if there is no way to use index to find rows.
Index Hint Syntax:
You can also use FORCE INDEX, which acts like USE INDEX (index_list) but with the addition that a table scan is assumed to be very expensive. In other words, a table scan is used only if there is no way to use one of the given indexes to find rows in the table.
Note that enabling general_log on a production server has overhead you should avoid it. You can check problematic queries from slow log.