Sql-server – Is selecting from the same server but different database slower than the same database

performancequery-performancesql server

I am thinking about 2 possibilities that I want to use in my project. So there are 2 projects, with different databases each. So Project P1, has Database D1, and Table T1. Project P2, has Database D2.

For Project P2, I need to select the data at Table T1 quite often. Is it better to create a replicate of T1 inside Database D2 (name it T2), and do SELECT * from T2 instead of doing SELECT * FROM [D1].[T1] ?

The 2 databases D1 and D2 are in the same server.

Best Answer

To add a bit to TomTom's comment: The optimizer has full access to meta-data etc regardless of whether the data is in one database or several databases. And the optimizer or execution engine is on constrained to one database. As long at it is in the same instance! If you talk about cross-instance queries (using linked servers, for instance), then you will definitely hurt!