English 中文(简体)
几千份最新消息,放缓
原标题:MySQL thousands of updates, slowing down
  • 时间:2010-04-20 23:05:36
  •  标签:
  • php
  • mysql

我需要运行一个总长度为100 000次(每张纸张开具约10 000次)的PHP lo,每个 lo有大约5个MySQL UPDATES。 当我跑了50次,需要3次。 当我跑了1 000次,需要约1300次。 你们可以看到,我的SQL正在以更多的人民民主党减缓ALOT。

这是最新的一个例子:

mysql_query("UPDATE table SET `row1`=`row1` +1 WHERE `UniqueValue`= 5 ");

它是随机产生于PHP的,但我可以将其储存在一个变数中,并管理它的每一 n。

是否有办法使MySQL和PHP能够以一致的速度运行(PHP储存隐藏的变数吗?),或将文字分开,这样做吗?

注:我为了发展目的,而不是为了生产目的这样做,因此只有1台电脑能够查阅数据。

最佳回答

http://www.php.net/manual/en/pdo.prepared-statements.php“rel=“nofollow noreferer”>。 两项主要好处之一是重复查询更为有效。

问题回答

更快速地利用类似的东西:

mysql_query("UPDATE table SET `row1`=`row1` + 1 WHERE `UniqueValue` IN (5, ... 10)");

假设你掌握独特的指数 理论价值。 你们可以提出多达8个有违约情况的咨监委的问询,但1个咨监委现在应当足够。 这将是一个巨大的问题,但得更快地,>

您还可以暂时完全取消指数更新,这样就能够使情况更快:

ALTER TABLE table DISABLE KEYS;
ALTER TABLE table ENABLE KEYS;

在N时间之后(如果你与InnoDB的表格一起工作),将汽车换成门并明确进行交易。

增加<代码>UniqueValue的索引,并删除<代码>row1和其他未使用的索引。

除了对<代码>的<>row1>和的“UniqueValue领域进行索引编制外,还确保它们使用诸如INTE/2005/>/code>等数字数据类型,并在中删除上的这些单一报价。 WHERE Clause.

mysql_query("UPDATE table SET `row1`=`row1` +1 WHERE `UniqueValue`=5");

Else MySQL需要将其编成册,然后送回/退出运行成本。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...