Home > database >  Could you tell me how to write the combination of the one-to-many table query, do not affect perform
Could you tell me how to write the combination of the one-to-many table query, do not affect perform

Time:10-09

The main article 40000 data
Id - & gt; The primary key
Home


Child table a total of 3.2 million data, the same ID 80 equipment
Id - & gt; The primary key
Equipment - & gt; The primary key
The device name

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Now I want to query the main house and child table device name
Picture side, id and houses, equipment (pops) is a retrieval conditions,

Is there anyone will not affect the performance under the premise of executable SQL

I am now writing found in [GROUP_CONCAT] performance is not very optimistic, who is a great god can tell me, how to write

CodePudding user response:

Can put the two tables of DLL and your SQL posted to see oh ~ first

CodePudding user response:

GROUP_CONCAT only to hit the post processing, but in memory, look at the way you query, not is the key factors influencing the query, manual multi-select won't choose the huge amounts of data

Did so key or check the connection using the index, for example on Anderson, d=b. equipment, so want to be in b equipment index is built on the field is valid, it with the where the query instead

CodePudding user response:

Query directly, don't use Group, find out the results, in the code Group
  • Related