August 29, 2006 at 11:50 am
August 29, 2006 at 11:52 am
From what you show us. Only a clustered index on id_s could be usefull.
Is there any other queries run on the temp table? Can we see the whole table definition?
August 29, 2006 at 12:29 pm
DDL
S_id int
Event int
UNIQUE_PERSONURN char
sDate Datetime
alter table #temp add constraint idx_pku Primary Key Clustered( SDate , Event , UNIQUE_PERSONURN)
Then Bulk insert happens in this order
Most Performed Insert
Insert into Testing
Select *
from #temp
where Event & 3 <> 0 and s_id = 564882 and RTRIM(Convert(varChar(10), p.SeizeDate , 112 )) = '20060822'
August 29, 2006 at 12:43 pm
Why do you need to do multiple inserts?
Why do you need to convert the datetime column in the table? The other way around would allow the server to use the clustered index.
Also if this is the only query running here.. You might be better served using this as the clustered index (even if it's not unique???) :
SeizeDate,s s_id, Event
August 29, 2006 at 1:17 pm
There is need to do multiple inserts as different files needs to be loaded onto the database, we dont have any other replication method.
The datatime column is being converted so as to make sure that the right date is being selected.
With those 3 columns you mentioned, they are already being used as a Clustered Primary key, but whilset checking the execution plan, I can see that its using a Clustered Index Scan, which isnt good. If I remove the promary key constraint, it uses a table scan, which isnt good either.
Where do i go now ?
August 29, 2006 at 1:25 pm
Well a scan isn't always a bad thing. If you are really inserting every row of the table, then a scan IS required. However I don't know enough about this task to tell you wether it can be sped up (a lot) or not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply