实现MySQL命令进度条

时间:2011-02-18 03:21:03

标签: c# mysql progress-bar

我们正在尝试解析文件并将其存储在MySQL数据库中。这些命令将导入一个大的跟踪文件,大小可能是几千兆字节,因此用户可能会对跟踪命令进度感兴趣。我们使用以下命令:

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;";

有没有办法在执行命令时跟踪进度以实现进度条?

1 个答案:

答案 0 :(得分:1)

您可以创建一个进度条,根据查询所在的阶段更改进度。绝对可以在查询中的某个位置放置GUID,然后使用SHOW FULL PROCESSLIST来确定查询的哪个阶段但是,没有确切的方法来衡量实际进展。使用InnoDB,您可以尝试使用SHOW INNODB STATUS,但即使这样也不准确。