【问题标题】:RoR: Monitor Indexing MigrationRoR:监控索引迁移
【发布时间】:2012-03-07 05:53:50
【问题描述】:

我计划在几个字段上为我的 1 亿行 (ruby on rails) 数据库编制索引,但问题是我无法知道这些迁移的进度。

通常,如果我正在运行手动数据迁移,我会做一个基本的i+=1;print("#{i},") 来跟踪迁移的进度,并确保它仍在工作。

有谁知道是否有办法通过我的索引迁移来做这样的事情,以便我可以监控它的进度?

【问题讨论】:

    标签: mysql ruby-on-rails database indexing


    【解决方案1】:

    您可以在一个进程中创建索引,同时在另一个进程中输出进度信息。它看起来像这样:

    pid = fork {
    
      # do index creation here
    
    }
    
    child_pid = nil
    begin
      child_pid = Process.waitpid(pid, Process::WNOHANG)
    
      # output progress info here
    
    end while child_pid.nil?
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-01
      • 1970-01-01
      • 2015-01-27
      • 2017-12-15
      • 1970-01-01
      • 1970-01-01
      • 2015-02-22
      相关资源
      最近更新 更多