SimonSellick
Programmer
Hi,
I'm running several queries from the wrong end of a dblink (the bulk of the data is at the far end). Most of them work well, but this one (see below) never returns (or at least, it has never returned by the time the db closes down each evening).
If I remove both of the LEFT JOINs the results come back within a minute or two, which is fine (there are about 50K resulting rows).
When I add just one of the LEFT JOINs back, the query doesn't run in a feasible time.
If I remove the local table and run the remaining query on the natural server (the one with all the rest of the data on it), it runs without the outer joins in about 30 seconds, but with both of them present, again it fails to run in a sensible time.
Again, on the local server, if I change the outer joins to inner, I get no records (fairly quickly), which is not entirely unexpected. If I alter just one of them, the results are quick and as expected.
Might this be an Oracle/ANSI-join problem? I can never remember the Oracle syntax for outer joins, but I do remember a problem with ANSI joins in version 8 (this is 9i).
I've run analyze table compute statistics on all four main tables, but I'm not well up on Oracle performance tweaks - and I suspect that I have done something daft rather than this being a simple tuning issue. I have no DBA permissions on either schema so there is in any case a limit to what I can achieve through tuning, but I have asked the DBA to look for any obvious resource issues, with no luck.
FWIW, the query is:
select count(*)
from gflows.u01@flot u
join gflows.gas_registrations@flot r
on r.meter_point_ref = u.meter_point_ref
and r.confirmation_effective_date <= u.creation_date + 7
join useful_dates d
on d.base_date = r.confirmation_effective_date
left join gflows.u03@flot
on u03.meter_point_ref = u.meter_point_ref
and u03.meter_reading_source = 'E'
and u03.creation_date between u.actual_read_date and p_end
left join gflows.m03@flot
on m03.meter_point_ref = u.meter_point_ref
and m03.read_type in ('B', 'E', 'M')
and m03.creation_date between u.actual_read_date and p_end
where u.creation_date between p_start and p_end
and u.meter_reading_source in ('E', 'M')
and u.actual_read_date between d.work_minus5 and d.work_plus5
Sorry about the length of this post. Any suggestions would be welcomed.
I'm running several queries from the wrong end of a dblink (the bulk of the data is at the far end). Most of them work well, but this one (see below) never returns (or at least, it has never returned by the time the db closes down each evening).
If I remove both of the LEFT JOINs the results come back within a minute or two, which is fine (there are about 50K resulting rows).
When I add just one of the LEFT JOINs back, the query doesn't run in a feasible time.
If I remove the local table and run the remaining query on the natural server (the one with all the rest of the data on it), it runs without the outer joins in about 30 seconds, but with both of them present, again it fails to run in a sensible time.
Again, on the local server, if I change the outer joins to inner, I get no records (fairly quickly), which is not entirely unexpected. If I alter just one of them, the results are quick and as expected.
Might this be an Oracle/ANSI-join problem? I can never remember the Oracle syntax for outer joins, but I do remember a problem with ANSI joins in version 8 (this is 9i).
I've run analyze table compute statistics on all four main tables, but I'm not well up on Oracle performance tweaks - and I suspect that I have done something daft rather than this being a simple tuning issue. I have no DBA permissions on either schema so there is in any case a limit to what I can achieve through tuning, but I have asked the DBA to look for any obvious resource issues, with no luck.
FWIW, the query is:
select count(*)
from gflows.u01@flot u
join gflows.gas_registrations@flot r
on r.meter_point_ref = u.meter_point_ref
and r.confirmation_effective_date <= u.creation_date + 7
join useful_dates d
on d.base_date = r.confirmation_effective_date
left join gflows.u03@flot
on u03.meter_point_ref = u.meter_point_ref
and u03.meter_reading_source = 'E'
and u03.creation_date between u.actual_read_date and p_end
left join gflows.m03@flot
on m03.meter_point_ref = u.meter_point_ref
and m03.read_type in ('B', 'E', 'M')
and m03.creation_date between u.actual_read_date and p_end
where u.creation_date between p_start and p_end
and u.meter_reading_source in ('E', 'M')
and u.actual_read_date between d.work_minus5 and d.work_plus5
Sorry about the length of this post. Any suggestions would be welcomed.