Is querying on views slower than doing one query?

前端 未结 5 793
悲哀的现实
悲哀的现实 2020-12-19 22:47

Will Mssql be even fast when I query on a view opposed to one query?

example

When I have this view:

create view ViewInvoicesWithCustomersNam         


        
5条回答
  •  猫巷女王i
    2020-12-19 23:04

    A view is simply a macro that is expanded/unnested into the main query. So these are equivalent.

    Note: if customername is in the Customer table, you've actually created an INNER JOIN. To filter for Bart's invoices and invoices with no customer you'd need to do this:

    select
      *
    from
      Invoices
      left join
      Customer on Customer.ID=Invoices.CustomerID and customername="Bart"
    

提交回复
热议问题