I have a SQL query of the form

SELECT ... FROM A@DB1 a, B@DB1 b, C@DB2 c
WHERE A.x = B.x and B.y = C.y

where the first two tables are dblinks to one database, and the last is on a second database. No local tables are accessed.

Explain Plan is showing a nested loop, even though all tables are big and I expect hash join in this situation. (If all tables were local, I'd expect hash join.)

The "explain plan" looks something like this:

NESTED LOOP 
    HASH JOIN        
        REMOTE     A
        REMOTE     B
    REMOTE         C

Further, refreshing stats seemed to have no effect.

Can someone please explain what factors influence how the joins over dblinks get split up and handed out to the remote DBs? Do any stats play a role in this process and how?

Also, is the 'nested loop' even the real problem, or something else entirely?
Maybe the real problem is pulling the full contents of A and B locally and joining, rather than joining/filtering remotely. (Perhaps a DRIVING_SITE hint would fix that?)

Thanks.

有帮助吗?
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top