I have a view that is:
SELECT a.Id
, a.col1
, a.col2
, b.col3
FROM a
LEFT OUTER JOIN b ON a.Id = b.Id
Table A takes very little time to query and table B takes a long time to query.
I want to query the view like so:
SELECT Col1
FROM view
In dev, this takes seconds because it drops table b. In prod (standard edition), it queries both tables and takes over a minute. Is there any way to tell the optimizer to not hit table b when this particular query is being run? Table B does not contain multiple Ids and this query does run with a correct query plan (and the same exact data in both tables) in dev.
I am using SQL Server 2019 Standard Edition in Prod and SQL Server 2019 Development Edition in dev. The tables are the same in both dev and prod.
I don't know what to try here. I had always expected the execution plan of a query with a left join to drop the outer table if no columns from it are selected.