How many where-clauses in mysql-query is too many?

不问归期 提交于 2019-12-24 02:32:04

问题


I have a table with many (maybe more than 500) different attributs in an "attribut"-column and wanted to find the rows, which contans many certan attributs (~ 200). The query to find them would contain a huge number of where-clauses.

How many where-clauses is okay, to have an acceptable performance?


回答1:


It's not the quantity that matters. It's how well you've designed your database structure and query that matter.

  1. Make sure you have an index on the columns that will be used in your where queries

  2. Place your WHERE statements in the order that will match the least rows first and proceed like that.

Here's MySQL's WHERE clause optimization guide for more tips



来源:https://stackoverflow.com/questions/11795414/how-many-where-clauses-in-mysql-query-is-too-many

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!