从另一个数据库执行时查询性能问题

Query performance issue when executing from another database

我尝试从另一个数据库执行查询,同时使用同义词和直接调用,如 select * from [DB].[schema].[view]

当我 运行 对原始数据库的查询时,它会在 1 秒内执行。如果我从另一个数据库调用视图,无论我是使用同义词还是像“[DB].[schema].[view]”这样的调用,执行都需要大约 1.5 分钟。 知道问题出在哪里吗?

USE DB
GO;
select * from schema.view //working fine : 1 second
GO;

use master
GO;
select * from db.schema.view //taking more than 1.5 minutes   
GO;

这似乎是兼容级别的问题。感谢这个post:https://dba.stackexchange.com/questions/194612/poor-performance-when-calling-query-from-another-db-on-same-server

奇怪的是,如果兼容级别为 140,我的性能很差,但如果我将兼容级别更改为 100,一切正常