Speed ​​up temp tables in SQL Server

I have 2 temporary tables # temp1 and #temp. Both have columns of keys and dates. Both have about 25 thousand lines. And I joined them based on a key and a date that are unique to all rows. It takes about 4 minutes to complete this connection. Is there any way to speed it up or any alternative methods?

+3
source share
4 answers

I believe that you can create indexes in temporary tables, as in any other tables.

+6
source

If your join of the tables 25ktakes 4minutes, something is wrong with it.

JOIN, ( - ), 25k * 25k = 625M.

4 , , , , .

, DISTINCT/GROUP BY, , .

, ?

+3

, . , .

?

+1

depending on what you are doing, you might be able to avoid temp tables altogether and have a set-based solution (which will work much faster and better), but it's hard to understand, even if you don't know.

+1
source

Source: https://habr.com/ru/post/1715967/


All Articles