All Products
Search
Document Center

Database Autonomy Service:GetStorageAnalysisResult

最終更新日:Dec 23, 2024

Queries the status and results of a storage analysis task.

Operation description

Note The physical file size indicates the actual size of an obtained file. Only specific deployment modes of database instances support the display of physical file sizes. The statistics on tables are obtained from information_schema.tables. Statistics in MySQL are not updated in real time. Therefore, the statistics may be different from the physical file sizes. If you want to obtain the latest data, you can execute the ANALYZE TABLE statement on the relevant tables during off-peak hours.
  • This operation is applicable only to ApsaraDB RDS for MySQL instances, PolarDB for MySQL clusters, and ApsaraDB for MongoDB instances.
  • For ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters, this operation works the same as the storage analysis feature of the previous version. Tasks generated by this operation cannot be viewed on the Storage Analysis page of the new version in the Database Autonomy Service (DAS) console. If you want to view the tasks and results, call the related API operation to obtain data and save data to your computer.
  • If you use an Alibaba Cloud SDK or DAS SDK to call this operation, we recommend that you use the latest version of the SDK.
  • If you use an SDK to call operations of DAS, you must set the region ID to cn-shanghai.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
hdm:GetStorageAnalysisResultnone
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
InstanceIdstringYes

The instance ID.

rm-bp10xxxxxxxxx
NodeIdstringNo

The node ID.

Note This parameter is reserved.
202****
TaskIdstringYes

The task ID. You can obtain the task ID from the response of the CreateStorageAnalysisTask operation.

910f83f4b96df0524ddc5749f615****

Response parameters

ParameterTypeDescriptionExample
object
Codelong

The HTTP status code returned.

200
Messagestring

The returned message.

Note If the request is successful, Successful is returned. Otherwise, an error message such as an error code is returned.
Successful
Dataobject

The data returned.

TaskIdstring

The task ID.

910f83f4b96df0524ddc5749f615****
TaskFinishboolean

Indicates whether the task is complete.

true
TaskSuccessboolean

Indicates whether the task is successful.

true
TaskStatestring

The status of the storage analysis task. Valid values:

  • INIT: The task is being initialized.
  • PENDING: The task is being queued for execution.
  • RECEIVED: The task is received for execution.
  • RUNNING: The task is being executed.
  • RETRY: The task is being retried.
  • SUCCESS: The task succeeds.
  • FAILURE: The task fails.
RUNNING
TaskProgresslong

The task progress.

Note Valid values are integers that range from 0 to 100.
50
TotalDbCountlong

The number of databases that need to be analyzed in the storage analysis task.

32
AnalyzedDbCountlong

The number of databases that have been analyzed.

2
StorageAnalysisResultobject

The details of storage analysis.

TotalStorageSizelong

The total size of instance storage.

Note Unit: bytes.
214748364800
TotalUsedStorageSizelong

The size of used storage.

Note Unit: bytes.
68345135104
TotalFreeStorageSizelong

The size of remaining storage.

Note Unit: bytes.
146403229696
DailyIncrementlong

The estimated average daily growth of the used storage space in the previous seven days. Unit: bytes.

0
EstimateAvailableDayslong

The estimated number of days for which the remaining storage space is available.

99
AnalysisSuccessboolean

Indicates whether the analysis on the database and table is successful.

true
AnalysisErrorTypestring

The reason why the analysis on the database and table fails.

  • DB_OR_TABLE_NOT_EXIST: The specified database or table does not exist.
  • DB_NOT_EXIST: The specified database does not exist.
DB_NOT_EXIST
NeedOptimizeItemListarray<object>

The items to be optimized, which are generated based on DAS default rules. You can ignore these items based on your business requirements, and create custom rules to generate items to be optimized based on other basic data that is returned.

needOptimizeItemListobject
DbNamestring

The name of the database.

testdb01
TableNamestring

The name of the table.

test_table
OptimizeItemNamestring

The item to be optimized. Valid values:

  • NEED_ANALYZE_TABLE: tables whose storage statistics obtained from information_schema.tables are 50 GB larger or smaller than the physical file sizes. This is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.

  • NEED_OPTIMIZE_TABLE: tables whose space fragments are larger than 6 GB and whose fragmentation rates are greater than 30%. The fragmentation rate of a table is generally calculated based on the following formulas:

    • ApsaraDB RDS for MySQL and PolarDB for MySQL: Fragmentation rate = DataFree/(DataSize + IndexSize + DataFree). In this topic, PhyTotalSize = DataSize + IndexSize + DataFree. Thus, the fragmentation rate can be calculated based on the following formula: Fragmentation rate = DataFree/PhyTotalSize.
    • ApsaraDB for MongoDB: Fragmentation rate = FragmentSize/PhyTotalSize.
  • TABLE_ENGINE: tables whose storage engines are not InnoDB or XEngine. This is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.

  • AUTO_INCREMENT_ID_BE_TO_RUN_OUT: tables whose usages of auto-increment IDs exceed 80%. This is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.

  • DUPLICATE_INDEX: tables whose indexes are redundant or duplicate. This is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.

  • TABLE_SIZE: single tables whose sizes are larger than 50 GB. This is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.

  • TABLE_ROWS_AND_AVG_ROW_LENGTH: single tables that contain more than 5 million rows and whose average row lengths exceed 10 KB. This is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.

  • TOTAL_DATA_FREE: instances whose reclaimable space is larger than 60 GB and whose total fragmentation rate is larger than 5%.

  • STORAGE_USED_PERCENT: instances whose space usage is larger than 90%.

NEED_OPTIMIZE_TABLE
OptimizeAdvicestring

The optimization suggestion. Valid values:

  • NEED_ANALYZE_TABLE: You can execute the ANALYZE TABLE statement on the table during off-peak hours. This is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.
  • NEED_OPTIMIZE_TABLE: You can reclaim fragments during off-peak hours.
  • CHANGE_TABLE_ENGINE_IF_NECESSARY: Change the storage engine type of a table after risk assessment. This is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.
  • AUTO_INCREMENT_ID_BE_TO_RUN_OUT: Pay attention to the usage of auto-increment IDs. This is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.
  • DUPLICATE_INDEX: Optimize indexes of tables. This is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.
  • TABLE_SIZE: Pay attention to the table size. This is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.
  • TABLE_ROWS_AND_AVG_ROW_LENGTH: Pay attention to the number of rows in a table and the average row length. This is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.
  • STORAGE_USED_PERCENT: Pay attention to the space usage to prevent the instance from being locked if the instance is full.
NEED_OPTIMIZE_TABLE
AssociatedDatastring

The data associated with the items to be optimized, which is in the JSON format.

{ "autoIncrementCurrentValue": 2147483647, "autoIncrementRatio": 1, "dbName": "testdb01", "maximumValue": 2147483647, "columnName": "id", "tableName": "test_table" }
TableStatsarray<object>

The information about the table.

tableStatsobject
DbNamestring

The name of the database.

testdb01
TableNamestring

The name of the table.

test_table
TableTypestring

The type of the table.

Note This parameter is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.
BASE TABLE
Enginestring

The type of the storage engine used by the table.

Note This parameter is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters.
InnoDB
PhysicalFileSizelong

The physical file size of the table. Unit: bytes.

Note This parameter is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters. Data of specific database instances cannot be obtained due to deployment mode.
3057655808
PhyTotalSizelong

The storage space of the table. Unit: bytes.

Note For ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters, the value of the parameter is the sum of DataSize, IndexSize, and DataFree. For ApsaraDB for MongoDB instances, the value of this parameter is the sum of DataSize and IndexSize.
3012493312
TotalSizelong
  • For ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters, this parameter indicates the amount of space occupied by table data and indexes. Unit: bytes. The value is the sum of DataSize and IndexSize.
  • For ApsaraDB for MongoDB instances, this parameter indicates the actual size of space allocated by Block Manager. Unit: Bytes. The compression ratio of an ApsaraDB for MongoDB instance is calculated based on the following formula: Compression ratio = TotalSize/DataSize.
3005153280
IndexSizelong

The storage space occupied by indexes. Unit: bytes.

1022296064
DataSizelong
  • For ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters, this parameter indicates the amount of space occupied by data. Unit: bytes.
  • For ApsaraDB for MongoDB instances, this parameter indicates the size of uncompressed data, that is, the amount of data. Unit: bytes.
1982857216
DataFreelong

The size of space fragments. Unit: bytes.

Note This parameter is applicable only to ApsaraDB RDS for MySQL instances and PolarDB for MySQL clusters. The fragmentation rate of a table is generally calculated based on the following formula: Fragmentation rate = DataFree/(DataSize + IndexSize + DataFree). In this topic, Fragmentation rate = DataFree/PhyTotalSize.
7340032
TableRowslong

The number of rows in the table.

12794732
AvgRowLengthlong

The average length of rows. Unit: bytes.

154
FragmentSizelong

The size of space that can be reclaimed. Unit: bytes.

Note This parameter is applicable only to ApsaraDB for MongoDB instances. Fragmentation rate = FragmentSize/PhyTotalSize.
362221568
RequestIdstring

The request ID.

B6D17591-B48B-4D31-9CD6-9B9796B2****
Successboolean

Indicates whether the request is successful. Valid values:

  • true
  • false
true

Examples

Sample success responses

JSONformat

{
  "Code": 200,
  "Message": "Successful",
  "Data": {
    "TaskId": "910f83f4b96df0524ddc5749f615****",
    "TaskFinish": true,
    "TaskSuccess": true,
    "TaskState": "RUNNING",
    "TaskProgress": 50,
    "TotalDbCount": 32,
    "AnalyzedDbCount": 2,
    "StorageAnalysisResult": {
      "TotalStorageSize": 214748364800,
      "TotalUsedStorageSize": 68345135104,
      "TotalFreeStorageSize": 146403229696,
      "DailyIncrement": 0,
      "EstimateAvailableDays": 99,
      "AnalysisSuccess": true,
      "AnalysisErrorType": "DB_NOT_EXIST",
      "NeedOptimizeItemList": [
        {
          "DbName": "testdb01",
          "TableName": "test_table",
          "OptimizeItemName": "NEED_OPTIMIZE_TABLE",
          "OptimizeAdvice": "NEED_OPTIMIZE_TABLE",
          "AssociatedData": "{\n    \"autoIncrementCurrentValue\": 2147483647,\n    \"autoIncrementRatio\": 1,\n    \"dbName\": \"testdb01\",\n    \"maximumValue\": 2147483647,\n    \"columnName\": \"id\",\n    \"tableName\": \"test_table\"\n}"
        }
      ],
      "TableStats": [
        {
          "DbName": "testdb01",
          "TableName": "test_table",
          "TableType": "BASE TABLE",
          "Engine": "InnoDB",
          "PhysicalFileSize": 3057655808,
          "PhyTotalSize": 3012493312,
          "TotalSize": 3005153280,
          "IndexSize": 1022296064,
          "DataSize": 1982857216,
          "DataFree": 7340032,
          "TableRows": 12794732,
          "AvgRowLength": 154,
          "FragmentSize": 362221568
        }
      ]
    }
  },
  "RequestId": "B6D17591-B48B-4D31-9CD6-9B9796B2****",
  "Success": true
}

Error codes

HTTP status codeError codeError message
400InvalidParamsThe request parameters are invalid.
403NoPermissionYou are not authorized to do this action.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-05-14The Error code has changed. The response structure of the API has changedView Change Details