Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
233 views
in Technique[技术] by (71.8m points)

database - EXPLAIN ANALYZE and other insertion related stats for INSERT command in MYSQL (8.0.20)

EXPLAIN ANALYZE was recently introduced for MYSQL but it only seems to work with SELECT. I am trying to find a similar command for INSERT which would print some insertion related statistics for each row that as it is inserted.

The following command does not work, but I am looking for a substitute for this.

EXPLAIN ANALYZE INSERT INTO table FROM <table>(col1, col2) values(val1, val2)

For some context, I am trying to insert into an AWS RDS MYSQL database using python and am looking to generate some insertion related metrics. Does it make sense to time each insertion command using python? What are some other ways of doing this?

question from:https://stackoverflow.com/questions/65865050/explain-analyze-and-other-insertion-related-stats-for-insert-command-in-mysql-8

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can't get EXPLAIN plans for INSERT with literal values - it should be obvious what the resulting workload will be. If not - its the sum of the carinality for each index divided by the number of records in the database + 1.

Does it make sense to time each insertion command using python?

No.

What are some other ways of doing this?

The DBMS is already doing this. And logging it. Also the logs will differentiate between time taken waiting for other queries to release locks and the time for the DML to run whereas your python code won't.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...