Is is possible to UNION ALL on multiple questions from different databases

Hi All,

I have a challenge where I would love to UNION ALL results from multiple SELECT statements that are querying different databases on the same connection?

Hi @asimumba
Yes, if you can make the SQL query in Metabase, then it is possible.
From a performance standpoint, I would recommend creating a View on the database instead, so the database will try to leverage its indexing and caching as much as possible, but it will always be painfully slow duo to UNION ALL (different databases have different query planners, but usually slow on most).
I usually ETL the data into a single consolidated table, so I can add indexes to that, which makes all queries against that table much faster.

1 Like

The challenge I have is that I have to select a database in metabase sql query window, which is limiting my results to that selected database.

I went with your suggested solution to create a view in the DB.