开发者

Implementing a MySQL command progress bar

We are trying to parse a file and store it in a My开发者_StackOverflow社区SQL database. The commands will be importing a large trace file the could be several gigabytes in size, so it it may of interest for the user to track the progress of the command. We are using the following command:

String commandText = "SET AUTOCOMMIT = 0; "
                   + "START TRANSACTION; "
                   + "LOAD DATA LOCAL INFILE \'" + filePath + "\' "
                   + "INTO TABLE testdatabase.metadata "
                   + @"FIELDS TERMINATED BY '\t' "
                   + @"LINES TERMINATED BY '\n' "
                   + "(Position,"
                   + "Timespace,"
                   + "Duration,"
                   + "Disk,"
                   + "Request,"
                   + "Sector,"
                   + "Length); "
                   + "COMMIT;";

Is there a way to track the progress while the command is being executed in order to implement a progress bar?


You can make a progress bar that changes progress based on the stage a query is in. It's definitely possible to put a GUID in a comment somewhere in the query, then use SHOW FULL PROCESSLIST to figure which stage a query is in. But there's no exact way of gauging actual progress. With InnoDB you can try using SHOW INNODB STATUS but even this isn't precise.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜