November 18, 2010 at 7:55 am
I have this simple query which returns 50 million records but it take mroe than 2 hrs, is there a way ti speed up this simple query.
select distinct *
into #t
from RevEmployee
where empcode= '098665877'
November 18, 2010 at 7:57 am
It will have to create a work table which it will use to get the distinct rows.
Do you need all columns to be distinct or can you get the primary key values from a subset (using a covering index hopefully) then join back to the table to get the rest of the columns.
I take it empcode is indexed? It would be worth checking whether the index is being used.
Cursors never.
DTS - only when needed and never to control.
November 18, 2010 at 8:12 am
yes, i need all columns and empcode is not indexed but many of the columns in the distinct are indexed and i cant change anything, is there any other simple trick to make it fast. thanks
November 18, 2010 at 8:16 am
If there was a simple trick , then the optimizer would probably be doing it already.
Since you hands are so severely tied , there really is not much that you can do.
November 18, 2010 at 8:40 am
Let me ask you what you are trying to accomplish. There may be a better/easier way to go about it.
That is a lot of "distinct" records returned.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply