MySQL “IN” operator performance on (large?) number of values

后端 未结 6 775
囚心锁ツ
囚心锁ツ 2020-11-28 03:26

I have been experimenting with Redis and MongoDB lately and it would seem that there are often cases where you would store an array of id\'s in either Mongo

6条回答
  •  广开言路
    2020-11-28 03:50

    IN is fine, and well optimized. Make sure you use it on an indexed field and you're fine.

    It's functionally equivalent to:

    (x = 1 OR x = 2 OR x = 3 ... OR x = 99)
    

    As far as the DB engine is concerned.

提交回复
热议问题