How to correlate query data combinations in the service layer?

the following sql statement is known:

select * from a left join b on a.id=b.id
where a.x=1 and b.yroom2;

this is a very common join table query in the db layer, but if the db layer does not allow the join table query operation, it can only be queried by querying a single table separately, and the query results can be combined in the service layer.

it is known that there is a large amount of data in the aformab table, so there is no better solution.

sort out:
1. You cannot do join table queries at the db layer.
2. Both tables have query conditions
3. Query results require data combination of two tables
4. Both tables have a large amount of data

Apr.05,2021

1: add an appropriate index according to the query field
2: in the case of effective use of the index, find out the data in table a, and then go to table b according to the data found in table a to obtain data in batches. If a finds a large amount of data, you can check it in batches.

Menu