Home > database >  Union all after the group by very slow
Union all after the group by very slow

Time:10-12

I wrote two SQL with union all together, the two period of detailed data, a total of only 100-300 line between, query soon in 2-6 seconds every time it came out, but the combined them after a select group by,,, very slow, and 6-9 minutes to come out as a result,,, really don't understand why this is so,,

CodePudding user response:

1, stick a SQL statement, and the corresponding implementation plan;
2, the original poster said SQL is 200 ~ 300 line? Should not data line number?

CodePudding user response:

Posted on the SQL statement and execution plan, only that, who can help you to solve the problem,

CodePudding user response:

Carefully look at the question tips,

CodePudding user response:

1, return a few rows of data and returns all the data that could satisfy the requirement of SQL is a different feeling;
2, to a large amount of data for group by operation also need to consume resources;
The first is to be clear: each of union all data query returns? How long does it take to return all of the data? Once again the best execution plan,
  • Related