# Slow INSERTs on one table

**URL:** <https://forums.percona.com/t/slow-inserts-on-one-table/1767>\
**Category:** Other MySQL® Questions\
**Created:** [February 21, 2012, 12:35am UTC](https://forums.percona.com/t/slow-inserts-on-one-table/1767 "2012-02-21T00:35:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesgolick](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jamesgolick](https://forums.percona.com/u/jamesgolick)\
**Post date:** [February 21, 2012, 12:35am UTC](https://forums.percona.com/t/slow-inserts-on-one-table/1767/1 "2012-02-21T00:35:21Z")

</div>

Queries like this are pretty common in our slow query logs:

228826-# User@Host: fetlife[fetlife] @ app4.dal.fetlife [10.18.5.79]  
228827-# Thread\_id: 42698 Schema: fetlife\_production  
228828-# Query\_time: 7.656149 Lock\_time: 0.000023 Rows\_sent: 0 Rows\_examined: 0 Rows\_affected: 1 Rows\_read: 2  
228829:INSERT INTO `friendship_requests` (`user_id`, `requested_by_user_id`, `created_at`, `updated_at`) VALUES (?, ?, ‘2012-02-21 03:37:50’, ‘2012-02-21 03:37:50’);

This table has been behaving funny for a while. Almost no lock time, only 2 rows read, 1 affected, and almost 8 seconds of runtime.

CREATE TABLE `friendship_requests` (  
`id` int(11) NOT NULL auto\_increment,  
`user_id` int(11) NOT NULL,  
`requested_by_user_id` int(11) NOT NULL,  
`created_at` datetime default NULL,  
`updated_at` datetime default NULL,  
PRIMARY KEY (`id`),  
UNIQUE KEY `index_friendship_requests_on_user_id_and_requested_by_user_ id` (`user_id`,`requested_by_user_id`),  
KEY `index_friendship_requests_on_user_id_and_created_at` (`user_id`,`created_at`)  
) ENGINE=InnoDB AUTO\_INCREMENT=13940603 DEFAULT CHARSET=utf8

and

±---------+  
| count(\*) |  
±---------+  
| 983848 |  
±---------+

No other table in our system has this issue.

Ideas?

---

<div class="post-metadata">

**Author:** ![xaprb](https://avatars.discourse-cdn.com/v4/letter/x/49beb7/32.png) [@xaprb](https://forums.percona.com/u/xaprb)\
**Post date:** [February 21, 2012, 8:46am UTC](https://forums.percona.com/t/slow-inserts-on-one-table/1767/2 "2012-02-21T08:46:42Z")

</div>

I think we need more info. I’d enable PROFILE in the slow query log and see what it says next time this happens.
