I need to insert into temp table “#Temp” 300 000 rows and 30 columns from different tables, I created indexes and inserting is very fast, it needs about 3 seconds. But then, when I want to read from this temp table it takes very long – about 3 minutes, can I do something for speed up this process?
It’s Microsoft SQL 2016
I tried to create index but it does not work at all, as I don’s need to use ORDER BY with the final result.
Do you have any idea how to solve this problem ?
SELECT
op.OperationId,
op.OperationTypeId,
op.BranchId,
op.DateUpdated,
op.OperationDate,
op.StepCountTypeId,
op.UserId,
op.StatusTypeId,
op.ChannelTypeId,
cash.Amount, cash.OperationPersonId, cash.CurrencyTypeId
INTO #Operation
FROM CashDesk.Cash.Operation op
LEFT JOIN CashDesk.Cash.CashOperation AS cash WITH (NOLOCK) ON op.OperationId=cash.OperationId
WHERE CAST(op.OperationDate AS DATE) BETWEEN '2024-04-01' AND '2024-04-30'
AND op.OperationTypeId IN (9, 11, 10, 13, 14, 15, 348, 369, 385, 432)
SELECT * FROM #Operation