Please consider a table with `queue_name`, `priority` and `message_timestamp` columns.

I'm going to perform the following query:

```
SELECT message_timestamp 
  from queue_messages 
 WHERE queue_name = 'name' 
   AND state = 0 
 ORDER 
    BY message_timestamp DESC 
 LIMIT 1

```

Here is a compound index for that:

```
CREATE INDEX STATE_QUEUENAME_TIMESTAMP ON `queue_messages` (queue_name, state, message_timestamp);

```

[![enter image description here](https://i.stack.imgur.com/ie2Ly.png)](https://i.stack.imgur.com/ie2Ly.png)

EXPLAIN shows that index matches the query pretty good (there is no filesort for `ORDER BY`):
[![enter image description here](https://i.stack.imgur.com/a7OYo.png)](https://i.stack.imgur.com/a7OYo.png)

My problem is that without `ORDER BY message_timestamp` I have throughput ~200 prs for this query, but with it ~50 rps!

And more rows in the table, slower the query with `ORDER BY`!

What am I doing wrong?