I am trying to left-merge two small tables given by sub-select and get an error message:
One of the predicates would lead to too big intermediate results. Table date_rabges_table has more than 5000000 rows or is bigger than 5000000 KB
The query that I use is given here:
select
*
from
(
select
date
from
dates_table
where
to_date('2010-01-01') <= date
and
date <= to_date('2014-01-01')
)
left join
(
select
min_date, max_date
from
date_ranges_table
where
i_id = 7
and
j_id = 13
)
on
min_date <= date
and
date < max_date
;
Some more details:
- The first sub-select gives just one column with dates between 2010-01-01 and 2014-01-01 (I think it is a bit more that 1400 dates)
- The second sub-select gives a table with two columns and two rows.
min_date max_date 2013-02-01 2013-05-01 2013-06-01 2013-07-01
I do not understand why I get the error message that I mentioned above. I am merging two tables that are small (about 1400 rows and exactly 2 row). The final results of left-join should not be larger than the table on the left. Where is the problem?