Is there a limitation to the length of the query in mysql?

前端 未结 2 1013
刺人心
刺人心 2020-12-07 01:02

I am asking this question because I need to know this limitation as I am generating SELECT query in my PHP script and the part of WHERE in this query is ge

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-07 01:44

    1. (if possible) Use WHERE metadata IN ('value1', 'value2')
    2. You may need to increase max_allowed_packet. It defaults to 16MB (client-side, and as low as 1MB server-side in older versions), and it's not that hard to construct a query that runs up against that limit (e.g., importing data from elsewhere with a giant INSERT query)

    LIKE '%string%' is a performance killer. Such a query can't use an index on that column. LIKE 'string%' on the other hand, is indexable

提交回复
热议问题