Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL is stuck in sorting state
    primarykey
    data
    text
    <p>Lately i have an issue with my website, the mysql load reaches 800% and most of the queries are stuck in "Sorting Result" set.</p> <p>The issue is that i've made a test. Same query with 1 result set, with sorting was taking 9,8 seconds and without it takes 0.02 seconds. The query contains where conditions and group by.</p> <p>The sql is optimized, the search is made in indexed fields and everything went fine until couple of days ago. No traffic spike, no code change, nothing.</p> <p>Did you had this issue in the past or do you have any idea how can i fix it?</p> <p>Thanks</p> <p>Edit: The explain of the query:</p> <pre><code> id: 1 select_type: SIMPLE table: m type: range possible_keys: posterid_to_idx,to,poster_id key: posterid_to_idx key_len: 8 ref: NULL rows: 6 Extra: Using where; Using filesort </code></pre> <p>Again, same query worked fine couple of days ago.</p> <pre><code> `id` int(11) NOT NULL AUTO_INCREMENT, `body` longtext NOT NULL, `poster_id` int(11) NOT NULL, `poster_name` varchar(50) NOT NULL, `to` int(11) NOT NULL, `added` int(11) NOT NULL, `picture` varchar(64) NOT NULL, `folder` int(11) DEFAULT NULL, `read` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `posterid_to_idx` (`poster_id`,`to`), KEY `to` (`to`), KEY `poster_id` (`poster_id`), KEY `msg` (`id`,`poster_id`,`to`), KEY `added` (`added`) ) ENGINE=InnoDB AUTO_INCREMENT=37548617 DEFAULT CHARSET=latin1 SELECT SQL_CALC_FOUND_ROWS m.body, m.id, m.poster_id, m.poster_name, m.to, m.added, m.picture, m.folder FROM messages m WHERE ((m.poster_id = '1885585' OR m.poster_id = '1886341') AND (m.to = '1886341' OR m.to = '1885585')) ORDER BY m.id DESC LIMIT 0, 10 </code></pre> <p>Top Output:</p> <pre><code>CPU: 6.0% user, 0.0% nice, 38.8% system, 0.2% interrupt, 55.0% idle Mem: 11G Active, 1400M Inact, 5451M Wired, 87M Cache, 4923M Buf, 29G Free Swap: 8000M Total, 8000M Free </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload