Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Lorna70
Starting Member
19 Posts |
Posted - 2010-05-24 : 11:18:50
|
HiI have created a view to link 3 tables together so that I can then create an sproc to narrow the records down depeding o the customer's search criteria. However, some of these tables are huge and I can't even run the View locally as it times out! My dilemma is - should I archive some records to reduce the number of records my View is dealing with and then go on to create the sproc or should I not bother with a View at all and only use an sproc for my query? In otherwords some advice as when to use Views and when not to would be great!ThanksLorna |
|
Kristen
Test
22859 Posts |
Posted - 2010-05-24 : 11:24:31
|
I doubt its the VIEW.If you doSELECT *FROM MyViewit will get all rows - which may be slow.but if you do:SELECT *FROM MyViewWHERE SomeColumn = 'ABC123'then it should be as fast as you would expect to select just that row.Otherwise you may have the JOINs wrong so that they are selecting gazzillions of rows.What doesSELECT COUNT(*)FROM MyViewreturn? Is that a reasonable number for the tables / criteria in your view? If not then you perhaps have (accidentally introduced) a Cartesian join |
 |
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2010-05-24 : 12:11:30
|
Views are for convenience, not for performance.--Gail ShawSQL Server MVP |
 |
|
vijays3
Constraint Violating Yak Guru
354 Posts |
Posted - 2010-05-24 : 13:54:38
|
When you have complex queries, that use many places in the stored procedures or functions, etc..,It will be used as security mechanism in the web applications. When we use the original table in the web applications the hackers may drop the table. That time the original data will be persist in the table.When you want to hide the particular columns to the specific people then we can create the specialized view.This is the fundamental use of creating views |
 |
|
|
|
|