MySQL slow_log table cannot be modified to innodb engine detailed explanation

MySQL slow_log table cannot be modified to innodb engine detailed explanation

background

Getting the slow query log from mysql.slow_log is slow, the table is a csv table and has no index.

I want to add an index to speed up access, but the csv engine cannot add indexes (the csv engine stores text separated by commas), so I can only change the storage engine to add indexes.

mysql.slow_log table can be changed to myisam, but not to innodb

mysql> set global slow_query_log=off;
Query OK, 0 rows affected (0.00 sec)

mysql> alter table mysql.slow_log engine=innodb;
ERROR 1579 (HY000): This storage engine cannot be used for log tables"
mysql> alter table mysql.slow_log engine=myisam;
Query OK, 33760 rows affected (0.37 sec)
Records: 33760 Duplicates: 0 Warnings: 0

mysql.general_log cannot be changed to innodb

mysql> alter table mysql.general_log engine=myisam;
Query OK, 242956 rows affected (2.41 sec)
Records: 242956 Duplicates: 0 Warnings: 0

mysql> alter table mysql.general_log engine=innodb;
ERROR 1579 (HY000): This storage engine cannot be used for log tables"

Official Documentation

According to the official documentation, the log table only supports the CSV engine and the MyISAM engine.

Why does it not support the innodb engine?

On what basis do you consider not supporting innodb tables?

Asked a friend

I guess the log table engine consumes a lot of redo and undo resources.

This is not necessary. . . These data are not important. .

Change log table storage engine

SET @old_log_state = @@global.general_log;
SET GLOBAL general_log = 'OFF';
ALTER TABLE mysql.general_log ENGINE = MyISAM;
SET GLOBAL general_log = @old_log_state;

Archive log table

USE mysql;
DROP TABLE IF EXISTS general_log2;
CREATE TABLE general_log2 LIKE general_log;
RENAME TABLE general_log TO general_log_backup, general_log2 TO general_log;

refer to

Selecting General Query Log and Slow Query Log Output Destinations

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • Explanation of the configuration and use of MySQL storage engine InnoDB
  • Summary of the differences between MySQL storage engines MyISAM and InnoDB
  • A Deep Dive into the MySQL InnoDB Storage Engine
  • Detailed explanation of the index and storage structure of the MySQL InnoDB engine
  • Change the MySQL database engine to InnoDB

<<:  Vue3.0+vite2 implements dynamic asynchronous component lazy loading

>>:  Summary of frequently used commands for Linux file operations

Recommend

A brief discussion on HTML table tags

Mainly discuss its structure and some important pr...

Reasons and solutions for the failure of React event throttling effect

Table of contents The problem here is: Solution 1...

MySQL uses limit to implement paging example method

1. Basic implementation of limit In general, the ...

Web Design Tutorial (2): On Imitation and Plagiarism

<br />In the previous article, I introduced ...

How to implement simple data monitoring with JS

Table of contents Overview first step Step 2 Why ...

MySQL stored procedure in, out and inout parameter examples and summary

Stored Procedures 1. Create a stored procedure an...

CSS code to achieve 10 modern layouts

Preface I watched web.dev's 2020 three-day li...

The top fixed div can be set to a semi-transparent effect

Copy code The code is as follows: <!DOCTYPE ht...

Detailed explanation of Svn one-click installation shell script under linxu

#!/bin/bash #Download SVN yum -y install subversi...

WeChat applet implements the Record function

This article shares the specific code for the WeC...

Detailed tutorial for installing influxdb in docker (performance test)

1. Prerequisites 1. The project has been deployed...

Summary of 4 solutions for returning values ​​on WeChat Mini Program pages

Table of contents Usage scenarios Solution 1. Use...

Comparison of the advantages of vue3 and vue2

Table of contents Advantage 1: Optimization of di...