Can I set a time limit for a slow SQL query?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 我能针对一个慢sql做限制时间?

| username: tidb狂热爱好者

I have a question. Can I set a time limit for a slow SQL query? But the SQL query seen on the dashboard looks like this:
SELECT
  COUNT(*) AS total
FROM
  co_order
WHERE
  (
    uid = ?
    AND STATUS IN (?, ?, ?, ?)
  ) [arguments: (501, 0, 1, 3, 5)]
How can I limit the execution time for such SQL queries with different user_ids but the same other parameters?


【TiDB Environment】Production, Testing, Research
【TiDB Version】
【Encountered Problem】
【Reproduction Path】`What operations were performed that led to the problem`
【Problem Phenomenon and Impact】

【Attachments】

> Please provide the version information of each component, such as cdc/tikv, which can be obtained by executing cdc version/tikv-server --version.
| username: xfworld | Original post link

There are several ways, which one do you prefer?

  1. hit processing

  2. configuration method

| username: 长安是只喵 | Original post link

You might have looked at the wrong tab. You need to check the slow query tab, not the statement analysis tab.

| username: h5n1 | Original post link

If you can’t change the program SQL, add a binding.

| username: system | Original post link

This topic will be automatically closed 60 days after the last reply. No new replies are allowed.