Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL: Performance penalty for joining two tables in separate schemas

Tags:

postgresql

Is there a performance penalty when joining two tables in separate schemas (However in the same database).

My physical model has several distinct sections that fit nicely into their own schemas, however I occasionally need to join across schemas and I've been unable to find any information on if this has a negative performance impact.

like image 217
Jonathan Holland Avatar asked Jul 08 '11 02:07

Jonathan Holland


People also ask

How do you join two tables in PostgreSQL?

In a merge join, PostgreSQL picks all join conditions with the = operator. It then sorts both tables by the join keys (which means that the data types must be sortable). Then it iterates through both sorted lists and finds matching entries.

Does PostgreSQL choose the wrong join strategy?

If PostgreSQL chooses the wrong strategy, query performance can suffer a lot. This article explains the join strategies, how you can support them with indexes, what can go wrong with them and how you can tune your joins for better performance.

Why does PostgreSQL take so long to join?

In both cases, a bad row count estimate is the cause of the problem. So while the join may be where we spend most of the execution time, the cause is a misestimate that happened earlier on. Find out what the best join strategy is (perhaps PostgreSQL is doing the right thing anyway).

What is join clause in PostgreSQL?

The PostgreSQL Joins clause is used to combine records from two or more tables in a database. A JOIN is a means for combining fields from two tables by using values common to each.


1 Answers

No, a schema is just a namespace.

Performance might be different when tables (or their indexes) are stored on different tablespaces. One tablespace might be on a fast storage device, the other on a slow one. But that's your choice and has nothing to do with a schema.

like image 196
Frank Heikens Avatar answered Nov 15 '22 22:11

Frank Heikens