Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Performance wise (view or Temp Table )Which one is better Expand / Collapse
Author
Message
Posted Tuesday, December 18, 2012 3:43 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, December 19, 2013 2:41 AM
Points: 20, Visits: 37
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
Post #1397663
Posted Tuesday, December 18, 2012 3:51 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 6:20 AM
Points: 5,218, Visits: 5,067
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?




Want an answer fast? Try here
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
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1397665
Posted Friday, December 21, 2012 5:58 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 9:38 PM
Points: 7,097, Visits: 12,598
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
Post #1399359
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse