开发者

What is wrong with this trigger in mysql?

Below is trigger that I need to create but It is not getting created.Please any bud开发者_开发问答dy 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


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜