I have 2 databases - both on the same server. Both databases also have their files on the same drives.
When I run a query on it's local DB, it runs in 3 secs.
However, when I run it from the second DB, it takes about 20mins! The only difference here is the Database name added to the FROM clause.
What can I look for to find why this performs so badly? Would statistics play a part?
The query is a SELECT one on a TVF. Unfortunately I cannot view the TVF as it is 3rd party query and I do not have access.