반응형
SQL Azure 테이블 크기
mssql2005에서 테이블 크기를 MB 단위로 가져오려면 EXEC sp_space used 'table'을 사용합니다.
쿼리나 API를 사용하여 SQL Azure의 특정 테이블에서 사용하는 공간을 얻을 수 있는 방법이 있습니까?
출처: Ryan Dunn http://dunnry.com/blog/CalculatingTheSizeOfYourSQLAzureDatabase.aspx
select
sum(reserved_page_count) * 8.0 / 1024 [SizeInMB]
from
sys.dm_db_partition_stats
GO
select
sys.objects.name, sum(reserved_page_count) * 8.0 / 1024 [SizeInMB]
from
sys.dm_db_partition_stats, sys.objects
where
sys.dm_db_partition_stats.object_id = sys.objects.object_id
group by sys.objects.name
order by sum(reserved_page_count) DESC
첫 번째 데이터베이스는 데이터베이스 크기를 MB 단위로 표시하고 두 번째 데이터베이스는 동일한 크기를 제공하지만 데이터베이스의 각 개체에 대해 크기가 큰 것부터 작은 것까지 순서대로 구분합니다.
다음은 테이블별로 행당 총 크기, 행 수 및 바이트 수를 제공하는 쿼리입니다.
select
o.name,
max(s.row_count) AS 'Rows',
sum(s.reserved_page_count) * 8.0 / (1024 * 1024) as 'GB',
(8 * 1024 * sum(s.reserved_page_count)) / (max(s.row_count)) as 'Bytes/Row'
from sys.dm_db_partition_stats s, sys.objects o
where o.object_id = s.object_id
group by o.name
having max(s.row_count) > 0
order by GB desc
다음은 위와 동일하지만 인덱스별로 분류한 쿼리입니다.
select
o.Name,
i.Name,
max(s.row_count) AS 'Rows',
sum(s.reserved_page_count) * 8.0 / (1024 * 1024) as 'GB',
(8 * 1024* sum(s.reserved_page_count)) / max(s.row_count) as 'Bytes/Row'
from
sys.dm_db_partition_stats s,
sys.indexes i,
sys.objects o
where
s.object_id = i.object_id
and s.index_id = i.index_id
and s.index_id >0
and i.object_id = o.object_id
group by i.Name, o.Name
having SUM(s.row_count) > 0
order by GB desc
이렇게 하면 더 큰 것을 위에 올릴 수 있습니다.
SELECT sys.objects.name,
SUM(row_count) AS 'Row Count',
SUM(reserved_page_count) * 8.0 / 1024 AS 'Table Size (MB)'
FROM sys.dm_db_partition_stats, sys.objects
WHERE sys.dm_db_partition_stats.object_id = sys.objects.object_id
GROUP BY sys.objects.name
ORDER BY [Table Size (MB)] DESC
언급URL : https://stackoverflow.com/questions/1957064/sql-azure-table-size
반응형
'programing' 카테고리의 다른 글
DockStyle 사용 방법.WPF의 표준 제어 장치를 채우시겠습니까? (0) | 2023.05.02 |
---|---|
유형이 있는 날짜보다 오래된 데이터 검색ORM (0) | 2023.05.02 |
보관 파일을 제출할 때 Xcode 6이 충돌합니다. (0) | 2023.05.02 |
Bash에서 명령이나 별칭에 "Y/n이 확실합니까?"를 추가하는 방법은 무엇입니까? (0) | 2023.05.02 |
Azure 응용 프로그램 설정이 내 appsettings.json 파일 값을 재정의하지 않음 (0) | 2023.05.02 |