database - MySQL: UPDATE too slow -
the following benchmark of series of queries have run. can see, updates slower other queries. what can speed them up?
0.0002 lock table category write; 0.0004 select @myleft := left_id category `amazon_browse_node_id` = 2675; 0.0184 update category set right_id = right_id + 2 right_id > @myleft; 0.0161 update category set left_id = left_id + 2 left_id > @myleft; 0.0007 insert category(`name`, `amazon_browse_node_id`, `category_seo_friendly_url`, `left_id`, `right_id`) values('training', 2697, 'training-2697/', @myleft + 1, @myleft + 2); 0.0004 unlock tables;
this problem related following problems (and attempt @ solution), posted here in so:
update:
create table if not exists `category` ( `category_id` int(11) not null auto_increment, `name` char(255) default null, `category_seo_friendly_url` char(255) default null, `left_id` int(11) default '1', `right_id` int(11) default '2', primary key (`category_id`), unique key `seo_friendly_url_unique` (`category_seo_friendly_url`), key `category_id` (`category_id`), key `left_id` (`left_id`), key `right_id` (`right_id`) )
the thing proper keys on right_id , left_id. then, updates slower selects or inserts. there not lot can it.
Comments
Post a Comment