I am trying to optimize a query that using IN clause in WHERE to avoid file sorting. To make it easy , I created the following sample which shows the problem. Here is my query: SELECT * FROM `test` WHERE user_id = 9898 AND status IN (1,3,4) order by id limit 30; Here is the result of explain, as you can see the query is filesort id select_type table type possible_keys key key_len ref rows Extra 1
![Optimize IN clause in where query with order by - MySQL](https://cdn-ak-scissors.b.st-hatena.com/image/square/2a53379c39df414b89526fa0b87c626122f0b7ef/height=288;version=1;width=512/https%3A%2F%2Fcdn.sstatic.net%2FSites%2Fdba%2FImg%2Fapple-touch-icon%402.png%3Fv%3D246e2cb2439c)