Home > database >  How to query by date table
How to query by date table

Time:09-26

The original MySql statement is:
 
Select count (distinct the testcases. Full_name)
The from jobs
Left the join perform on perform.com pare said=1
And perform. Performvalue & lt;> '
And perform. Gvalue & lt;> '
And jobs. Id=perform. Job_id
Left the join the testcases on perform. Testcase_id=the testcases. Id
Left the join testplans on perform. Testplan_id=testplans. Id
Left the join perform_items on perform. Performitems_id=perform_items. Id
Where
Date_format (jobs) testdate, 'Y - m - % d % %)=' 2019-12-31 '


Now perform month according to the table, each table data about five million
This how to rewrite the SQL to query all perform the SQL table, the great god, please give directions,

CodePudding user response:

Or split the SQL statement above, the table of each month with the above SQL execution again, then code layer aggregation query results, is that ok?
PS, perform after table, data useful within a year, up to twelve tables,

CodePudding user response:

With the view, the union all tables

CodePudding user response:

refer to the second floor of gypsy song response:
in view of the union all tables can be
union all performance can

CodePudding user response:

reference ZKeeer reply: 3/f
Quote: refer to the second floor of gypsy song response:

In view of the union all tables can be
union all performance please

Is not the performance is good, there is no other better way,

Besides, performance mainly depends on the index and if you can use SQL written to the index,
  • Related