Use data from two databases in one question

Is it possible to source data from two different databases both connected to Metabase and use it in the same question?

3 Likes

No; when dealing with multiple databases, data should be consolidated within a data warehouse for many proven design choices, but ignoring that, most query linguistics are designed to deal with only one server at a time, and the “questions” in Metabase are just nicely formatted queries with a few differences in design.

How do you have your servers set up?

We do not currently support joining across multiple databases.

Like @Mike says, it’s generally a good idea to bring any data you want to query together into a single data warehouse. We strongly recommend you deal with the pain of bringing together data “On Write” vs “On Read” in terms of analytics queries.

If you absolutely must kludge something together, we’ve seen people use PostgreSQL foreign data wrappers and do joins across those. Just be aware that it’s a particularly expensive form of technical debt.

1 Like

postgres FDW is an option, but as sameer mentioned, its expensive from technical debt, if its simple lookup then its OK, for large joins its really better to avoid it

oracle db-links work similar way and are reasonably simple to tune with hints and easier to setup and maintain than postgres FDW (though I feel postgres FDW are more flexible for non-ODBC source)

you can also look at “virtual data warehouse” solutions like Denodo (did not try it), their express version is free http://www.denodo.com/en/denodo-platform/denodo-express - when I talked to them years ago, their solution was based on postgres and connection using plain postgres driver, not sure if its still the case. If it is, it could possibly work with metabase

Depending on what you want to exactly do (your question does not speak about JOIN) you can do what you intend to do by specifying properly your path to the tables across the different databases : if you use microsoft sql server, you will use the following syntaxe

database1.dbo.tableN

instead of

tableN

Had to perform a union of queries on a former table and new replacing table and it worked perfectly.

regards

Is there any plan to put this feature into RoadMap?

@dibyendu.roy
There’s a feature request open - go and vote by clicking the :+1:

1 Like

hi @vectalis can you explain further on the union you did. Currently facing this problem. I need to join queries from two different DBS on Metabase.

His answer is specific to MS SQL Server. What database are you using?

I am using postgresSQL for RDMS

You can use DBLink. I've never tried it an it's supposed to be very restricted, especially with joins across databases.

A very important question. It's very uncomfortable without it. I ask developers to pay attention to this request. Thank you in advance!

there are plenty of options to do this right now, please check presto/trino, foreign data wrappers, etc