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:
- not running bulk UPDATEs against the products table
- not using WHERE clauses that do not use indexes
- not using WHERE clauses whose indexes are ignored by the MySQL Optimizer
精彩评论