John W. Vinson replied to Kamil
20-Mar-10 06:17 PM

I have been thinking about this for a day or so and I cannot think of any *good*
way that does not require sending a lot of information up or down the wire. A
Passthrough query would at least put the load on the remote Oracle database
(which I expect can handle it easily, though the DBA might not appreciate the
suggestion!), but if you need to upload *your* entire table every time to do
the comparison, you are not ahead. My only suggestion would be to at least try
doing the query in a "frustrated outer join" rather than the not-equals WHERE,
since the latter will probably force a full table scan:
SELECT RemoteTable.*
FROM RemoteTable
LEFT JOIN LocalTable
ON RemoteTable.A = LocalTable.A
AND RemoteTable.B = LocalTable.B
WHERE LocalTable.A IS NULL;
This will find all records in RemoteTable which do not exist in LocalTable
(based on the keys), but of course will not find records which exist in both
tables but have been changed. The query optimizer might be able to come up
with a better plan, but if LocalTable is very large it will still require a
lot of data be moved.
--
John W. Vinson [MVP]