Why MySQL OR is slower than IN

A technical analysis examines why MySQL queries using chains of OR conditions can run far slower than equivalent IN lists. In one example, a COUNT(*) query on MySQL 8.4 examining only 1 million rows logged a query time of about 67,254 seconds. CPU profiling showed roughly 99% of time spent in Item_cond_or::val_int, with most of it in Item_func_eq comparisons. MySQL turns id = 1 OR id = 2 ... OR id = N into a single Item_cond_or holding N equality items, which are evaluated one by one for each row.

AI-written summary, checked against the cited sources. How summaries work

Read at Planet MySQL