The question is not how to perform joint queries, but some people say that it is best not to use multi-table joint queries for large data volumes, therefore, it is optimal to know how to write an SQL statement to retrieve the paging data list from multiple tables. Supplement: Suppose there are two tables: Table A is the master table, and table B's data is the screening of Table... the question is not how to perform joint queries, but some people say that it is best not to use multi-table joint queries for large data volumes, therefore, it is optimal to know how to write an SQL statement to retrieve the paging data list from multiple tables.
Supplement: Assume that there are two tables: Table A is the master table and table B is one of the filtering conditions for querying Table.
Reply content:
The question is not how to perform joint queries, but some people say that it is best not to use multi-table joint queries for large data volumes, therefore, it is optimal to know how to write an SQL statement to retrieve the paging data list from multiple tables.
Supplement: Assume that there are two tables: Table A is the master table and table B is one of the filtering conditions for querying Table.
First, identify the ids of a table record, and then use in query for another table
There is no specific business scenario to talk about optimization.
Add the redundant fields of Table B in Table A. You can obtain one page of content directly by querying Table A. Other information of the associated table B can also be obtained directly, you can also obtain the data in the cache using the id of Table B.
Such optimization will increase maintenance costs, but the lower the paradigm level, the higher the query efficiency.
For reference only.
In some special business scenarios, joint queries are required. It cannot be blindly optimized.
Ids in queries. Tens of thousands of ids are obtained. It is better to directly join the query. Although this solution is good.
Optimization refers to optimization without affecting the business.
Paging can refer to http://segmentfault.com/q/10100000001...
To optimize the query, We need to optimize the data structure first, and think about whether you have to use two tables, but not one row. You can also understand the built-in database functions, such as left (), right (), substring (), and substring_index (). There are also mid () and substr (). Do not move LIKE and so on, mainly write more, according to the actual application scenario to make the best judgment.
By the way, MYSQL configurations can also be optimized, such as query_cache.