Improved Performance For Temp Table

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
jstorm13
Forum Newbie
Posts: 12
Joined: Wed Oct 10, 2007 12:40 pm

Improved Performance For Temp Table

Post by jstorm13 »

Hello:

Can anyone tell me if this should work out ok. I don't really like working
on my live server but want to make a change.

----------------------------------------------------
Currently I have:
~~~~~~~~~~~~~~~~~
SELECT
blah,
blah,
blah
into #temptable
FROM SourceTable
INNER JOIN ........

I am having some performance issues. I have read
not to use Select Into.
----------------------------------------------------
I am thinking about using:
~~~~~~~~~~~~~~~~~~~~~~~~~~
SELECT *
INTO #temptable
FROM SourceTable
WHERE 1 = 0

CREATE clusteredindex iname on #temptable (blah, blah)

INSERT #temptable
SELECT *
FROM SourceTable
INNER JOIN ..............

I am hoping this will improve performance but I want
to be sure I have the syntax correct. If I create
the clustered index then insert the data will it
work the way I am hoping?
----------------------------------------------------


Thanks for any help on this guys...
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

what database server you're using? oracle, mssql, something else?
Post Reply