In Thinkphp, does the mysql table query use inids or leftjoin (in paging mode, ids arrays are usually about 20 )?

Source: Internet
Author: User
I don't know which solution. Fortunately, we can see in the book that table sharding queries are generally used. it is helpful for caching. I don't know which solution is better.
In the book, we can see that table sharding queries are generally used to facilitate caching.

Reply content:

I don't know which solution is better.
In the book, we can see that table sharding queries are generally used to facilitate caching.

It mainly depends on the data volume and application scenarios. when the data volume is small, the two are similar.
Which of the following is a better efficiency for where in () queries or multi-table left join queries?

You are talking about an SQL problem. using left join is far more than using in.

These two syntaxes are used in different scenarios. in knows the id to filter records that match your id group, while left join is an associated table. If I do paging, check whether the associated table is a large table (hundreds of thousands of millions of records), and then decide whether to use left join. even if we use join, we 'd better explain whether it is optimal, if not, check the explain results for optimization. We recommend that you do not join large tables. if you use in, extract IDs and query sub-tables to assemble data into the master table dataset without repeating multiple cycles, and the efficiency is not necessarily slow.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.