June 10, 2009 at 12:42 am
Hi All,
When i am executing the following query
select count(*) from LinkedServer.SourceDatabase.dbo.sourcetable
It is running more than 3 hours to complete...
Pls let me know why this scenario happening...
Thanks in Advance,
June 10, 2009 at 2:17 am
marees.inspire (6/10/2009)
Hi All,When i am executing the following query
select count(*) from LinkedServer.SourceDatabase.dbo.sourcetable
It is running more than 3 hours to complete...
Pls let me know why this scenario happening...
Thanks in Advance,
It will for sure perform a full table scan to accomplish this !!
Try to access the catalog objects to perform that.
Downside is that it may not be 100% exact !
IMO it would be better to ask a view like this
e.g.
Create view V_Catalog_RowCount
as
select sum(p.row_count) as Row_Count , min(s.name + '.' + o.name) as TableName, o.object_id
from LinkedServer.SourceDatabase.sys.objects o
inner join LinkedServer.SourceDatabase.sys.schemas s
on (o.schema_id = s.schema_id)
and s.name 'sys'
inner join LinkedServer.SourceDatabase.sys.indexes i
on (o.object_id = i.object_id)
and i.index_id in (0,1)
inner join LinkedServer.SourceDatabase.sys.dm_db_partition_stats p
on o.object_id = p.object_id
and p.index_id in (0,1)
group by o.object_id --s.name + '.' + o.name
--where o.object_id = object_id(@Composed_Obj_Name)
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply