Slow view with lots of calculations

I created a view that does a lot of calculations and references several tables. If I do a

select * from linkview

everything comes up instantaneosly. However, if I do a

select * from linkview where id='12345'

it is mind numbingly slow. Which makes it seem that the problem is not the calculations, but querying the view. I am using SQL server 6.5.

I suggest you do the following: Run the query using a straight select statement instead of using a view. So instead of “select from view where …” combine the SQL statement used to create the view with the clause specifying an id.

If the timing is slow, it means that you don’t have the index you need to support the additional limitation (that is, id = ‘12345’). However, if, in fact, the query runs fine through a select statement but degrades through a view, you are facing a different issue.

I’ve seen cases where the plan that the Optimizer decides on for a view is not updated when an additional where clause is entered–just as in your case. For that reason, I stopped using views in many cases. To be honest, it might have been fixed in later releases or service packs. I’m not even sure I didn’t pick up this prejudice from version 4.2.

The good news is that I verified that version 7 deals with this correctly.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS