Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display the transaction and related SQL #671

Open
crazycs520 opened this issue Jul 3, 2020 · 3 comments
Open

Display the transaction and related SQL #671

crazycs520 opened this issue Jul 3, 2020 · 3 comments

Comments

@crazycs520
Copy link
Collaborator

crazycs520 commented Jul 3, 2020

Feature Request

Is your feature request related to a problem? Please describe:

Add a page such as below:

image

It's easy to see the total time of each transaction type and the related SQL in the transaction, and the time gap between each SQLs.

How to classify the transaction?

We can generate a digest for the transaction:

Here is a transaction example:

1. begin
2. select ...
3. update ...
4. update ...
5. commit

if SQL 3 and SQL 4 in the upper has same SQL digest, we the transaction SQL digest can be below:

sql_1 digest 
sql_2 digest 
sql_3 digest  -- suppose SQL 4 has the same digest with SQL 3
sql_5 digest 

Then we can use upper sql digests to generate a transaction digest.

How to collect the information?

Set tidb_slow_log_threshold variable to 0 value, then TiDB will record the every execute SQL. Then use txn_start_ts to get the sqls that execution in the transactions. such as below:

SELECT  MIN(time)
       ,COUNT(*)
       ,MIN(query_time)
       ,AVG(query_time)
       ,MAX(query_time)
       ,SUM(query_time)
       ,MIN(query)
       ,MIN(plan)
FROM `SLOW_QUERY`
WHERE txn_start_ts=417754666182377492 
AND time > "2020-07-01 20:43:50" 
AND time < "2020-07-01 20:45:53" 
GROUP BY  digest,plan_digest
ORDER BY MIN(time)\G
@scsldb
Copy link

scsldb commented Jul 7, 2020

What kind of scene will be used?

@breezewish
Copy link
Member

@scsldb This reveals how TiDB clients (e.g. JDBC / Application) send SQL queries, which can identify the root cause when TiDB resource is not fully utilized.

@breezewish
Copy link
Member

Dependent project: #710

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants