November 1, 2021 at 4:42 pm
Hi:
I have a view as
create view vwOpsasselect * from tableAwhere type = 'S'
When I run the view as select * from vwOps where ID = 24 it takes 15 secs.
Whereas when I run the query it returns the records in 2 secs.
select * from tableAwhere type = 'S'and ID = 24
I ran with statistics time IO and found that when I run the view the returned rows are more whereas with query it is less. Any idea what could be the reason?
November 1, 2021 at 4:59 pm
First try refreshing the view. The "*" in the view may be causing some issues if the table has changed after the view was created.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
November 1, 2021 at 5:58 pm
It definitely could, esp. if there's an index containing the type column.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply