Mysql – Amazon RDS Slow Query Log Does Not Show SQL Statement

amazon-rdsMySQL

I enabled the slow query log on Amazon RDS and I executed a "select sleep(5)". But when I look at this table, how is it that sql_text does not show the actual SQL statement?

mysql> select * from mysql.slow_log\G
*************************** 1. row ***************************
    start_time: 2021-01-27 15:45:08.033183
     user_host: XX
    query_time: 00:00:05.002547
     lock_time: 00:00:00.000000
     rows_sent: 1
 rows_examined: 0
            db: test
last_insert_id: 0
     insert_id: 0
     server_id: 3213123123
      sql_text: 0x73656C65637420736C656570283529
     thread_id: 103213

Below are the settings:

log_output = TABLE
slow_query_log = 1
long_query_time = 1
log_slow_admin_statements = 0
log_queries_not_using_indexes = 0

What I am not sure is why I got this output:
sql_text: 0x73656C65637420736C656570283529 which I suspect is the select sleep(5) ?


Update:

I ran this again to make sure I didn't execute select HEX(sleep(5)), and I didn't do that. Also, the sql_text are all the same even though I ran different SQl statements.

mysql> select sleep(3);
+----------+
| sleep(3) |
+----------+
|        0 |
+----------+
1 row in set (3.09 sec)

mysql> select * from mysql.slow_log\G
*************************** 1. row ***************************
    start_time: 2021-01-27 15:45:08.033183
     user_host: XX
    query_time: 00:00:05.002547
     lock_time: 00:00:00.000000
     rows_sent: 1
 rows_examined: 0
            db: 
last_insert_id: 0
     insert_id: 0
     server_id: 1499
      sql_text: 0x73656C65637420736C656570283529
     thread_id: 107032
*************************** 2. row ***************************
    start_time: 2021-01-28 21:26:11.324022
     user_host: XX
    query_time: 00:00:02.000258
     lock_time: 00:00:00.000000
     rows_sent: 1
 rows_examined: 0
            db:
last_insert_id: 0
     insert_id: 0
     server_id: 1499
      sql_text: 0x73656C65637420736C656570283229
     thread_id: 103121
*************************** 3. row ***************************
    start_time: 2021-01-28 21:26:46.160363
     user_host: XX
    query_time: 00:00:03.000205
     lock_time: 00:00:00.000000
     rows_sent: 1
 rows_examined: 0
            db:
last_insert_id: 0
     insert_id: 0
     server_id: 1499
      sql_text: 0x73656C65637420736C656570283329
     thread_id: 110323
3 rows in set (0.10 sec)

Also, I tested with log_output = FILE and I see the correct SQL statements. See below.

# Time: 2021-01-28T21:18:10.623686Z
# User@Host: XX Id: 131232
# Query_time: 1.000215 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0
SET timestamp=1611868690;
select sleep(1);

Best Answer

Check various settings:

log_output = TABLE    # versus FILE
slow_query_log = ON
# slow_query_log_file = (fullpath to some file)
long_query_time = 1
log_slow_admin_statements = ON       # optional
log_queries_not_using_indexes = OFF  # optional