Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Sql query becomes slowest

Author  Topic 

napilut
Starting Member

2 Posts

Posted - 2011-08-05 : 05:58:02
I'm from Spain and my English is too poor. Forgive me.

We are actually working with SQL server 2005 db.

There is a query, that uses some temporally tables (5), that was working fast and correctly some months ago until now (from few seconds to more than a minute). The query has not been edited.

The first thinq we've thought was that the server disc space was running out, however the server disc space is correct.

What else can it be? Do you have any sugestion?

Thanks.

Jordi.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-08-05 : 06:14:14
Have you updated the statistics?
What have happened to the granularity of index columns?



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

napilut
Starting Member

2 Posts

Posted - 2011-08-05 : 08:38:02
The statistics have been updated, but it does not solves the problem.

This problem is very strange. The problem is bout the temporary table but I don't understand why. It was working fine and fast during some months until now.

There is a part of the query code where the temporary table is filled with three selects:

insert into #tempTable
select ...
insert into #tempTable
select ...
insert into #tempTable
select ...

This code takes about a minute. If I comment out the insert statement:

--insert into #tempTable
select ...
--insert into #tempTable
select ...
--insert into #tempTable
select ...

The three selects take less than a second.
(The #tempTable is not used inside the select statement)

Why?

Thank you!
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-08-05 : 10:28:40
Are your physical files fragmented?


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2011-08-05 : 10:49:56
Does the Temp database needs CHECKDB run on same??? Corruption?
Go to Top of Page
   

- Advertisement -