# WHERE IN slow when the IN list is long

**URL:** <https://forums.percona.com/t/where-in-slow-when-the-in-list-is-long/7196>\
**Category:** Percona Server for MySQL 8.0\
**Created:** [September 12, 2019, 6:36am UTC](https://forums.percona.com/t/where-in-slow-when-the-in-list-is-long/7196 "2019-09-12T06:36:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![0815](https://avatars.discourse-cdn.com/v4/letter/0/839c29/32.png) [@0815](https://forums.percona.com/u/0815)\
**Post date:** [September 12, 2019, 6:36am UTC](https://forums.percona.com/t/where-in-slow-when-the-in-list-is-long/7196/1 "2019-09-12T06:36:25Z")

</div>

Hello,

below is my query. It is very slow and I wonder if there is anything that makes it faster.  
This is generated by a forum software and is not or only conditionally changeable.

Does anyone have a helpful idea?

The tables have the following number of records.  
xf\_forum: ~4000 xf\_node: ~4000 xf\_user: ~442.406 xf\_thread: ~598.012 xf\_forum\_read: 9.342 xf\_thread\_read: 286 Unfortunately I can’t specify the whole query! There are about 3000 IDs

```auto
SELECT `xf_forum`.*, `xf_node_Node_1`.*, `xf_user_LastPostUser_2`.*, `xf_thread_LastThread_3`.*, `xf_forum_read_Read_4`.*, `xf_thread_read_Read_5`.* 
FROM `xf_forum` LEFT JOIN `xf_node` AS `xf_node_Node_1` ON (`xf_node_Node_1`.`node_id` = `xf_forum`.`node_id`) LEFT JOIN `xf_user` AS `xf_user_LastPostUser_2` ON (`xf_user_LastPostUser_2`.`user_id` = `xf_forum`.`last_post_user_id`) LEFT JOIN `xf_thread` AS `xf_thread_LastThread_3` ON (`xf_thread_LastThread_3`.`thread_id` = `xf_forum`.`last_thread_id`) LEFT JOIN `xf_forum_read` AS `xf_forum_read_Read_4` ON (`xf_forum_read_Read_4`.`node_id` = `xf_forum`.`node_id` AND `xf_forum_read_Read_4`.`user_id` = '90052') LEFT JOIN `xf_thread_read` AS `xf_thread_read_Read_5` ON (`xf_thread_read_Read_5`.`thread_id` = `xf_thread_LastThread_3`.`thread_id` AND `xf_thread_read_Read_5`.`user_id` = '90052') WHERE (`xf_forum`.`node_id` IN (2249, 230, 63, 326, 372, 93, 2032, 2976, 96, 687, ......)) 

```
