I am running a query that gives me a collection of date objects for some months between date ranges. Does, but is very slow (~ 2 seconds on my local machine, 30 in our corporate development environment). The message is: Select ADD_MONTHS (TO_DATE ('200,804', 'YYYYMM'), -1 + ROWNUM) as the month from all_objects where ADD_MONTHS (TO_DATE ('200804', ' 'YYYYMM'), -1 + ROWNUM) & lt; = TO_DATE ('200,805', 'YYYYMM')
Currently, it will return only one month, but if you are expanding the second date string, this returns more.
I have two questions. First, why did it run so slow? I know that Oracle works are actually a question slow, but it takes about 30 seconds on a work machine on my work
second, more intriguing question:. Why the order is small for one part of each other, when you increase the border, then say '201805'? I think it takes the opposite effect in a large range that takes longer time.
There is no need to use inline views and I look at the much used date function If you leave all this, then it remains:
SQL & gt; Var START_YM varchar2 (6) SQL & gt; Var END_YM varchar2 (6) SQL & gt; Exec: START_YM: = '200804'; : END_YM: = '201805' The PL / SQL process successfully completed SQL & gt; Selection Add_months (TO_DATE (: START_YM, 'YYYYMM'), Level 1) M2 Dual Level 3 L & amp; Connect; = Months_between (TO_DATE (: END_YM, 'YYYYMM'), TO_DATE (: START_YM, 'YYYYMM')) +1 4 / M ------------------- 01-04 -2008 00:00:00 01-05-2008 00:00:00 01-06-2008 00: 00: 00 & lt; ... 116 rows left ... & gt; 01-03-2018 00:00:00 01-04-2018 00:00:00 01-05-2018 00:00:00 122 rows selected Whatever seems to be easy ...
Regards, Rob.
Comments
Post a Comment