I have a query that is essentially
SELECT *
FROM foreign_table_a
LEFT JOIN local_table_b on foreign_table_a.id = local_table_b.id
I'm looking at the explain analyse in datagrip and I don't really get any information other than I spend most of my time in the foreign scan.
How do I figure out what is going on in the foreign table? Do I need to parse out the sql that is running that foreign scan and run an explain on the foreign server?
I'm also not sure why there is a nested loop being used for this join. Everything being compared has an index so you would think it would be more effecient, right?
Also, the foreign table is actually a view. Is it possible to collect statistics on that foreign view using ANALYZE
?
explain(analyze, verbose, buffers)
on the remote server, for that part that is handled in this databaseSELECT * FROM foreign_table_a
) and run the explain on the foreign server with that? And that will give me an accurate representation of what is happening? What happens if I have a condition at the end such as (where foreign_table_a.grade > 80). Would that be filtering the foreign view first and then joining?ANALYZE foreign_view_name
help out at all in this case then?