mysql中这个触发器有什么问题?

发布于 2024-08-29 14:02:06 字数 599 浏览 0 评论 0原文

下面是我需要创建的触发器,但它没有被创建。请任何朋友可以解释一下这个触发器有什么问题吗?请帮助我。

DELIMITER $$
 CREATE TRIGGER property_history_update 
 AFTER UPDATE ON `properties`
 FOR EACH ROW BEGIN

 IF OLD.ListPrice != NEW.ListPrice THEN  
    INSERT INTO `property_history` 
      SET ListingKey = OLD.ListingKey,
           ListPrice = NEW.ListPrice,
       ListingStatus = OLD.ListingStatus,
     LastUpdatedTime = NEW.LocalLastModifiedOn;
 END IF;

END$$
DELIMITER ;

当我执行上面的触发器时,出现如下错误:

致命错误:第 99 行 /var/www/phpmyadmin/libraries/import/sql.php 中的最大执行时间超过 300 秒

Below is trigger that I need to create but It is not getting created.Please any buddy can explain me what is wrong with this trigger ? Help me please.

DELIMITER $
 CREATE TRIGGER property_history_update 
 AFTER UPDATE ON `properties`
 FOR EACH ROW BEGIN

 IF OLD.ListPrice != NEW.ListPrice THEN  
    INSERT INTO `property_history` 
      SET ListingKey = OLD.ListingKey,
           ListPrice = NEW.ListPrice,
       ListingStatus = OLD.ListingStatus,
     LastUpdatedTime = NEW.LocalLastModifiedOn;
 END IF;

END$
DELIMITER ;

When I executed above trigger I got error as below :

Fatal error: Maximum execution time of 300 seconds exceeded in /var/www/phpmyadmin/libraries/import/sql.php on line 99

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伪装你 2024-09-05 14:02:06

通过不带 WHERE 子句的 UPDATE 传递属性中的所有行将具有线性(O(n) [n 是行数的因子])运行时间。如果所有行的 ListPrice 都发生变化,则该时间可能会加倍。

示例:如果您运行“UPDATE properties SET ListPrice = 5;”并且表中有 10,000 行,请放心,property_history 表中将有 10,000 个 UPDATE 和最多 10,000 个 INSERT。

请确保三 (3) 件事:

  1. 不对产品表运行批量更新
  2. 不使用不使用索引的 WHERE 子句
  3. 不使用其索引被 MySQL 优化器忽略的 WHERE 子句

Passing through all rows in the properties via an UPDATE without a WHERE clause will have a linear (O(n) [n is factor of the number of rows]) running time. That time can double if all rows experience a change in ListPrice.

Example: If you ran "UPDATE properties SET ListPrice = 5;" and there are 10,000 rows in the table, rest assured there will be 10,000 UPDATEs and upto 10,000 INSERTs into the property_history table.

Please make sure you of three(3) things:

  1. not running bulk UPDATEs against the products table
  2. not using WHERE clauses that do not use indexes
  3. not using WHERE clauses whose indexes are ignored by the MySQL Optimizer
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文