Reputation: 43
I'm having VERY bad performance with UPDATE on MySQL, my update statement is quite basic like:
UPDATE `tbl_name`
SET `field1` = 'value1', `field2` = 'value2' .. `fieldN` = 'valueN'
WHERE `tbl_name`.`id` = 123;
values are few (15), all TEXT kind and WHERE condition is just one using id. values are JSON strings (but this should not bother to MySQL, it should see them as just plain text).
In "tbl_name" I have few records (around 4k).
The problem is that executing this UPDATE statement I got 8 seconds of execution time (taken from MySQL slow query log).
I'm running MySQL alone on an EC2 High CPU Medium istance and I think it's pretty impossible that these performances are "normal", I would expect much more performance.
Do you have any idea to investigate the problem?
** UPDATE ** Thank you for your fast answers, table is InnoDB and id is a PRIMARY, UNIQUE. Values are TEXT (not varchar)
** UPDATE bis ** No, id is an integer, all other fields are TEXT
Upvotes: 3
Views: 1053
Reputation: 89
Since MySQL do not support EXPLAIN UPDATE
statements before version 5.6.3, we're quite blind about this query. Try USE INDEX
statement...
I've launched the same on my server. All was ok with 15 TEXT
fields and 4096 rows of quite arbitrary text. It was ok with both USE INDEX(PRIMARY)
and IGNORE INDEX(PRIMARY)
statements.
So, I suppose, you have problems with your SQL server, installation package, or whatever, not query...
Upvotes: 1