SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Performance wise (view or Temp Table )Which one is better


Performance wise (view or Temp Table )Which one is better

Author
Message
Raghu.K
Raghu.K
Valued Member
Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)Valued Member (62 reputation)

Group: General Forum Members
Points: 62 Visits: 43
Hi ,

Table A is having 1 million Records, Table B is having 100 million Records.
I need to show data (for report pupose) from both the tables using join basing conditions.

Which one is better : View or Temp Table (Performance wise)
Please help me in that
anthony.green
anthony.green
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: General Forum Members
Points: 63232 Visits: 8598
Depends what you are trying to do.

Please follow the link in my signature on posting code and data for the best help.

But with a temp table you would have to load and then read, where as a view would be a read so less going on via a view.

That being said why not a procedure?

What is the structure of the tables?
What is the index definitions on the tables?
What is the joining criteria?
Is there referential integrity between the tables?



How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


Orlando Colamatteo
Orlando Colamatteo
SSC Guru
SSC Guru (105K reputation)SSC Guru (105K reputation)SSC Guru (105K reputation)SSC Guru (105K reputation)SSC Guru (105K reputation)SSC Guru (105K reputation)SSC Guru (105K reputation)SSC Guru (105K reputation)

Group: General Forum Members
Points: 105012 Visits: 14506
Regular views offer nothing from a performance standpoint. Views are simply replaced by their definition in the query submitted for execution and then optimized as if the query submittor had supplied the entirety of the view-query themselves.

For example, if I have a view named dbo.SomeData defined as:

CREATE VIEW dbo.SomeData
AS
SELECT ColumnName FROM dbo.SomeTable;
GO



and I say

SELECT * FROM dbo.SomeData;



this (in general terms) is what the query engine will eventually optimize after view-replacement is done:

SELECT * FROM (SELECT ColumnName FROM dbo.SomeTable);



__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search