Why does putting a WHERE clause outside view have terrible performance

前端 未结 5 1193
萌比男神i
萌比男神i 2021-02-12 21:00

Let\'s say you have a view:

CREATE VIEW dbo.v_SomeJoinedTables AS
SELECT
    a.date,
    a.Col1,
    b.Col2,
    DENSE_RANK() 
      OVER(PARTITION BY a.date, a.         


        
5条回答
  •  生来不讨喜
    2021-02-12 21:13

    It's called "Predicate pushing" aka deferred filtering.

    SQL Server doesn't always realise the WHERE can be applied "earlier", inside the view effectively.

    It has been mitigated in SQL Server 2008 to work more as expected

提交回复
热议问题