简体   繁体   中英

best practice for mysql search query (select)?

在mysql中进行数据搜索的最佳做法是:1-提取100条记录,然后在数据库外进行过滤,或者在mysql数据库中使用WHERE并提取所需的确切记录,即使WHERE有点复杂(也涉及索引列)2-使用或不JOIN

Doing filtering outside the database is a sign you're doing it wrong. WHERE exists to do the filtering for you. If your conditions take a long time to apply, you probably need to index better.

Using EXPLAIN can help identify where problems in your query exist.

If you can't figure out how to tune your JOIN , you can try deliberately de-normalizing your data to improve performance. Keep in mind that requires duplicating data and keeping it in sync so it's something that is usually a last resort.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM