Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

view vs table in sql server

Posted on 2011-03-08
4
Medium Priority
?
616 Views
Last Modified: 2012-05-11
i am using query from C# to sql server. my question is, i can get data from the views as well as tables. which one is better for performence for query? which one is better to use for select query?
please help
0
Comment
Question by:Amitava_Mukherjee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 500 total points
ID: 35068390
It depends what it is a View of. If it is just a subset of a single table then the View will be as quick as the table. Views can be indexed so Views that draw data from multiple tables can be quicker than the same query run inline because the view can be indexed independently of the underlying tables.
0
 
LVL 30

Accepted Solution

by:
Olaf Doschke earned 1000 total points
ID: 35068427
A view by general definition is a virtual table as it selects with more or less complex SQL from one or more real tables. From that perspective you can do both.

A view has the advantage to keep the knowledge about the queries at the database level. You can argue, that the business logic level of the c# application is also a good place for that, but the view can of course be used by many applications connecting to the same database.

Doing stored procedures instead of views could even be a better choice for keeping cahed meta data like the execution plan.

What you can't do is update a view, so you'd need to write changes to the underlying tables.

Pros and cons mainly are about abstraction layers of the application business logic and database/persitence layer. See here for further discussion: http://stackoverflow.com/questions/1004974/use-sql-view-or-sql-query

Bye, Olaf.
0
 
LVL 5

Assisted Solution

by:mayankagarwal
mayankagarwal earned 500 total points
ID: 35068461
if your view is based on multiple tables, and if you have to put loops in your code to access the data from the multiple tables and for sure view will give you the better performance, becuse the number of hits to the database will be descreased.

0
 

Author Closing Comment

by:Amitava_Mukherjee
ID: 35068565
thanx
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question