Home > database >  The efficiency is too low, this sentence everyone a great god has a better suggestion? Get one of th
The efficiency is too low, this sentence everyone a great god has a better suggestion? Get one of th

Time:10-05

Select t. *
The from MONITOR_TEST t
Where tc ollect_date in
(select Max (collect_date)
The from MONITOR_TEST
Where collect_date & lt; To_date (' 2016-11-08 ', '- dd yyyy - mm)
And collect_date & gt; To_date (' 2016-11-04 ', '- dd yyyy - mm))
The union
Select t. *
The from MONITOR_TEST t
Where tc ollect_date in
(select min (collect_date)
The from MONITOR_TEST
Where collect_date & lt; To_date (' 2016-11-08 ', '- dd yyyy - mm)
And collect_date & gt; To_date (' 2016-11-04 ', '- dd yyyy - mm))

CodePudding user response:

It will take the data at the same time?

CodePudding user response:

Collect_date indexed? Have the index should not be too slow, feeling your records should be higher selectivity
In can switch=
The union can be replaced by union ALL

CodePudding user response:

1, the maximum and minimum together read
Select Max (collect_date), min (collect_date)
The from MONITOR_TEST
Where collect_date & lt; To_date (' 2016-11-08 ', '- dd yyyy - mm)
And collect_date & gt; To_date (' 2016-11-04 ', '- dd yyyy - mm)
And then to compare the business
2, collect_date efficiency exist on reasonable index will be higher

  • Related