douchen4915 2014-12-30 09:32
浏览 246

LOAD DATA INFILE +进度跟踪

I made a PHP console script that downloads big CSV file (> 2.5m rows) and insterts it to the database. I'm using LOAD DATA INFILE query here and it works perfectly, taking ~20 seconds to complete.

I'd like to track progress of this query. I've read about several approaches here, but I don't know how to run LOAD DATA INFILE query and then run progress tracking loop. The script waits until LOAD DATA INFILE is done.

My database is MySQL and the engine is InnoDB. I'm using Laravel framework.

  • 写回答

1条回答 默认 最新

  • drau89457 2015-01-25 05:29
    关注

    You can "split" the dump file with pt-fifo-split and print progress message after each chunk.

    For example, in shell:

    f=dump.sql
    nlines=`cat $f | wc -l`
    let chunk=$nlines/100
    
    pt-fifo-split --lines $chunk $f
    i=0
    while [ -e /tmp/pt-fifo-split ] 
    do 
        echo "$i% is done"
        mysql -e "LOAD DATA INFILE '/tmp/pt-fifo-split' INTO ..."
        let i=$i+1
    done
    
    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程