Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 查询tidb近半年执行过的sql语句
According to the R&D requirements, it is necessary to query and save the SQL statements executed in the past six months for problem tracing. Does TiDB-v5.4 have related functions?
What you might need is the enterprise edition features.
How long can the community edition query the most recent SQL statements executed?
Enabling this parameter will do.
I have tried enabling the tidb_general_log
parameter, which writes the executed SQL statements to the TiDB log. Is there a way to write them to a separate log or save them in another way?
You can directly query it in the database.
SELECT * FROM INFORMATION_SCHEMA.CLUSTER_LOG WHERE time > '2022-11-11' AND time < '2022-12-12' AND MESSAGE LIKE '%[GENERAL_LOG]%'
If it is for audit purposes, it is recommended to use the TiDB commercial version service.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.