May 21, 2013 at 5:15 am
We have a tall table that contains 2.6 billion rows
Table structure:
The application which uses this table has been running slow for the last couple of days and it seems to have happened following the addition of about 400 million rows last weekend.
I think it's because of the index fragmentation although I'm not sure how to check if this the case without affecting the application?
So my first question is, how do I check to see if the indexes are fragmented and whether the stats need updating on such a large table?
---------------------------------------------------------
It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens[/url]
Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
May 21, 2013 at 6:26 am
SELECT
database_id, object_name(object_id), object_id, index_id, partition_number, index_type_desc,
alloc_unit_type_desc, index_depth,
index_level, avg_fragmentation_in_percent, fragment_count, avg_fragment_size_in_pages, page_count,
avg_page_space_used_in_percent, record_count, ghost_record_count, version_ghost_record_count, min_record_size_in_bytes,
max_record_size_in_bytes, avg_record_size_in_bytes, forwarded_record_count
FROM
sys.dm_db_index_physical_stats
( 5, NULL, NULL, NULL, 'DETAILED' )
where object_name(object_id) = 'TableName'
Try this , if avg_fragmentation_in_percent is more than 30 then it is index fragmentation.
Regards
Durai Nagarajan
May 21, 2013 at 6:30 am
Index fragmentation is quite unlikely to cause sudden slow performance. Index fragmentation is in fact only a concern when you're doing large range scans from disk.
Now statistics, that's a lot more likely to be the problem. Try a stats update with fullscan (yes, it'll take a while) and see if that helps.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
May 21, 2013 at 6:59 am
Thanks to you both.
Not sure why I said index fragmentation. When my colleague mentioned it to me, the first thing I asked him was about the stats lol.
Was thinking along the lines of 400 million new rows = out of date stats = inappropriate execution plans for the queries etc...
---------------------------------------------------------
It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens[/url]
Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
May 21, 2013 at 7:10 am
yeah i would have thought of statistics as the issue as well;
ok we know it takes 20% of the rows int he table , + 500 rows to trigger auto updates of statistics.
so if you insert 400M rows, is that 400M out of 3000M (13.33 % affected?) or is that 400M of 2600M rows that were already there?(15.38 % affected?)
Lowell
May 21, 2013 at 7:17 am
The 2.6 billion total is after the insert of the 400 million.
---------------------------------------------------------
It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens[/url]
Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
May 21, 2013 at 7:21 am
Abu Dina (5/21/2013)
The 2.6 billion total is after the insert of the 400 million.
cool to have such big table, I'm actually a bit jealous, because it presents a lot more opportunities for learning when fiddling with lots of data. lots of chances to increase experience in tuning, maintenance, etc.
Lowell
May 21, 2013 at 7:46 am
Lowell (5/21/2013)
Abu Dina (5/21/2013)
The 2.6 billion total is after the insert of the 400 million.cool to have such big table, I'm actually a bit jealous, because it presents a lot more opportunities for learning when fiddling with lots of data. lots of chances to increase experience in tuning, maintenance, etc.
To be honest a lot of the time I feel out of my depth but as you say, it's a great opportunity to learn new skills in the two key areas you mentioned.
My boss (who owns half the company) and an accomplished developer herself ran a delete statement (this was last month).... It took the whole application down for 5 days!
Oh and it's the first time I got to use COUNT_BIG 😛
---------------------------------------------------------
It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens[/url]
Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
May 21, 2013 at 7:56 am
I have another question. Any implications running DBCC SHOW_STATISTICS on a live system with this big table?
---------------------------------------------------------
It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
David Edwards - Media lens[/url]
Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
Howard Zinn
May 21, 2013 at 8:08 am
No. Show statistics doesn't touch the table
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
May 21, 2013 at 10:39 am
With 2.6 billion rows, be mindful of those INT datatypes. You have probably already considered that, just throwing it out there.
May 22, 2013 at 7:31 am
nivek-224024 (5/21/2013)
With 2.6 billion rows, be mindful of those INT datatypes. You have probably already considered that, just throwing it out there.
Your comment is referring to the maximum 2,147,483,647 value for Int datatype?
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
May 22, 2013 at 7:34 am
Abu Dina (5/21/2013)
We have a tall table that contains 2.6 billion rowsTable structure:
The application which uses this table has been running slow for the last couple of days and it seems to have happened following the addition of about 400 million rows last weekend.
I think it's because of the index fragmentation although I'm not sure how to check if this the case without affecting the application?
So my first question is, how do I check to see if the indexes are fragmented and whether the stats need updating on such a large table?
I notice that your clustered index is on IX_dType. Why was that column chosen to cluster the table. Especially for tables with a large number of rows, you typically want to cluster on a column with unique sequential values. There could very well be fragmentation.
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
May 22, 2013 at 7:41 am
Try running below query, will return you tables list with last statistic updated date and rows updated later on, these tables requires a statistics update with FullScan
SELECT OBJECT_NAME(id),name,STATS_DATE(id, indid),rowmodctr
FROM sys.sysindexes
WHERE STATS_DATE(id, indid)<=DATEADD(DAY,-1,GETDATE())
AND rowmodctr>0
AND id IN (SELECT object_id FROM sys.tables)
May 22, 2013 at 8:01 am
I would disagree there, stats that are more than a day old and have a single row change absolutely do not need updating. That's almost as bad as blanket updating everything.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 15 posts - 1 through 15 (of 22 total)
You must be logged in to reply to this topic. Login to reply