dongya6997 2012-08-08 01:08 采纳率: 0%
浏览 51
已采纳

Mysql隐形进程?

Here is a table

Id   Date   Name     vendor
1   | 123  |  jungle     |  qwe
2   | 43   |  jungle     |  qwe
3   | 678  |  jungle     |  ewq
4   | 678  |  jungle     |  ewq
5   | 678  |  jungle     |  ewq
6   | 678  |  jungle     |  hgjghj

This script removes rows from the table that have duplicate values in the name column and also have the same vendor value. Leaving only one unique row. The script is also executed via XHR ajax call $.post(), after clicking a button on the front end.

$sql = DELETE x
FROM $table x
JOIN 
 ( SELECT vendors
        , email
        , MIN(lead_id) min_lead_id 
     FROM $table
    WHERE vendors = $vendor
    GROUP BY vendors
           , email
 ) y 
ON y.vendors = x.vendors 
AND y.email = x.email
AND y.min_lead_id <> x.lead_id;

mysql_query($sql, $conn);
echo json_encode($foo);

and the result

Id   Date   Name     vendor
1   | 123  |  jungle     |  qwe
3   | 678  |  jungle     |  ewq
6   | 678  |  jungle     |  hgjghj

Now with a table of 50k it finishes in two seconds. Or rather, it returns an ajax call via the echo json_encode($result);. Now at that point I assume the process is complete but after going into my mysql table and refreshing again and again, I find out that mysql is still running because the total number of rows reported in the table keeps changing as if its still running query.

How do I make echo json_encode($result); wait until the database is finished updating? Or is there a better way to resolve this? Thanks.

$("#complete_dedupe").live("click", function(e) {
    e.preventDefault();
    table_name = $('#IMEXp_import-selectTable-select option:selected').val();
    $.post("dedupevendor.php", {"table": table_name}, function(data) {
        count_dedupe = 0;
        count_dedupe = data;
        $("#dupe_vendor").append(count_dedupe);
        $("#tr2").fadeIn("slow");
        vendor = $("#vendor_hidden").val();
        $("#edit_par4").append(vendor);
    }, "json")
});

By continually refreshing phpmyadmin, the circled number changes for the duration of about less than a minute. This only happens right after I run my dedupe script and right after the script already returns from the ajax call. The picture is below

enter image description here

  • 写回答

2条回答 默认 最新

  • dongmu4591 2012-08-08 03:01
    关注

    The reason you're not seeing a change in phpMyAdmin is that Innodb doesn't keep a running count of rows, like MyISAM does.

    Instead of looking at the table summary, run this; it should change when you run your de-dupe script.

    SELECT COUNT(*) FROM auto;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制