May 5, 2006 at 2:46 pm
Hi:
I have the following query:
select col11,col12,col13=' ',col14 into dbo.table1
from remoteserver.database.dbo.table2 where col15>=(SELECT col21 FROM table1 WHERE col22 = 101)
Local server: 2000
Remote server: 7
Col15 and col21 are datetime
It takes 15 minutes to finish.
If I change to col15>='2006-05-05 00:00:00.000' (the output from SELECT col21 FROM table1 WHERE col22 = 101) it takes 10 seconds.
The collate_name from col21 is null, but from what I know, collation doesn't apply to datetime columns.
What can be happening?
Thanks in advance.
Regards.
May 5, 2006 at 2:51 pm
How long does it take to run the SELECT col21 FROM table1 WHERE col22 = 101 statement? Is col22 indexed?
May 5, 2006 at 2:56 pm
Nothing. It has 5 rows.
May 5, 2006 at 3:04 pm
Have you tried rewriting the select with a join?
select col11,col12,col13=' ',col14
into dbo.table1
from remoteserver.database.dbo.table2
INNER JOIN table1
ON table2.col15 >= table1.col21
WHERE table1.col22 = 101
May 5, 2006 at 3:22 pm
Yes. Same bad performance.
Same if using a variable (datetime), storing the value and comparing the remote date against it. Only working when value is "hardcoded".
May 5, 2006 at 3:22 pm
How many rows are in remoteserver.database.dbo.table2 (the sql 7 server)?
May 5, 2006 at 3:26 pm
BTW do you have Distributed Transaction Coordinator runnin or not?
May 5, 2006 at 3:31 pm
Yes. Both servers autostart DTC.
May 5, 2006 at 3:32 pm
You missed my other question:
How many rows are in remoteserver.database.dbo.table2 (the sql 7 server)?
May 5, 2006 at 3:35 pm
Sorry Antares, didn't see your previous question: 750.000 rows. Twelve satisfying the where clause.
May 5, 2006 at 3:40 pm
What I believe happens in a non-static call such as this is that all 750,000 records are pulled across then filtered so you loose the advantage of all the indexes you might be using. You should see this in the execution plan if I remember correctly. However I am trying to find the details on this because I haven't done for 3 years now and forget what options you have available.
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply