Enable Performance Schema

更新时间:
复制 MD 格式

Database Autonomy Service (DAS) uses MySQL Performance Schema to collect data for the new version of Performance Insight. To use the new version of Performance Insight, you must enable Performance Schema. This topic describes how to enable Performance Schema.

Prerequisites

  • The database instance must be one of the following:

    • ApsaraDB RDS for MySQL

      Note
      • ApsaraDB RDS for MySQL Basic Edition is not supported.

      • ApsaraDB RDS for MySQL 5.5 is not supported.

    • ApsaraDB MyBase for MySQL

    • PolarDB for MySQL

  • A database instance with 8 GB or more of memory

  • A database instance in one of the following regions: China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Shenzhen), China (Chengdu), China (Hong Kong), Singapore, Malaysia (Kuala Lumpur), or Indonesia (Jakarta)

Background information

For more information about Performance Schema, see the official MySQL documentation.

Considerations

  • Enabling Performance Schema requires a database instance restart. We recommend performing this operation during off-peak hours and ensuring that your application has a reconnection mechanism.

  • Enabling Performance Schema consumes additional instance resources. For more information, see the Performance Schema stress test report.

Procedure

  1. Log in to the console of your database instance.

  2. In the top navigation bar, select a region and click the ID of the target instance.

  3. Navigate to the Parameters page.

    • For ApsaraDB RDS for MySQL, click Parameter Settings in the left-side navigation pane.

    • For PolarDB for MySQL, choose Settings and Management > Parameters in the left-side navigation pane.

  4. Enable the performance_schema parameter.

    • For ApsaraDB RDS for MySQL 5.6, set the Running Value of the performance_schema parameter to ON.

      Important

      For ApsaraDB RDS for MySQL 5.7 and 8.0, if the database instance meets the prerequisites (at least 8 GB of memory), the performance_schema parameter is enabled by default.

    • For PolarDB for MySQL, select Cluster and set the Cluster Parameter for performance_schema to ON.

      Important

      For PolarDB for MySQL 5.6 and 5.7, set the Cluster Parameter for loose_performance_schema to ON.

    You can run the SHOW GLOBAL VARIABLES LIKE'%performance_schema'; command to check the status of the performance_schema parameter.

  5. For ApsaraDB RDS for MySQL, verify that the following parameters have values greater than 0. Otherwise, Performance Insight cannot collect data. For PolarDB for MySQL, no configuration is required.

    Note
    • For ApsaraDB RDS for MySQL 5.6, some of the following parameters cannot be configured. Modify only the configurable parameters.

    • For more information about the parameters, see the official MySQL documentation.

    performance_schema_accounts_size
    performance_schema_digests_size
    performance_schema_error_size
    performance_schema_max_digest_length
    performance_schema_hosts_size
    performance_schema_max_digest_sample_age
    performance_schema_max_index_stat
    performance_schema_max_sql_text_length
    performance_schema_max_statement_classes
    performance_schema_max_statement_stack
    performance_schema_users_size
    performance_schema_setup_actors_size
    performance_schema_setup_objects_size
    performance_schema_max_thread_classes
    performance_schema_max_thread_instances
    performance_schema_max_file_classes
    performance_schema_max_file_instances
    performance_schema_max_table_handles
    performance_schema_max_table_instances

    Sample values (configure based on your actual workload):

    loose_performance_schema_accounts_size=1000
    loose_performance_schema_digests_size=10000
    loose_performance_schema_error_size=10000
    loose_performance_schema_max_digest_length=1024
    loose_performance_schema_hosts_size=1000
    loose_performance_schema_max_digest_sample_age=60
    loose_performance_schema_max_index_stat=10000
    loose_performance_schema_max_sql_text_length=1024
    loose_performance_schema_max_statement_classes=256
    loose_performance_schema_max_statement_stack=10
    loose_performance_schema_users_size=10000
    loose_performance_schema_setup_actors_size=10000
    loose_performance_schema_setup_objects_size=10000
    loose_performance_schema_max_thread_classes=100
    loose_performance_schema_max_thread_instances=10000
    loose_performance_schema_max_file_classes=256
    loose_performance_schema_max_file_instances=1000
    loose_performance_schema_max_table_handles=10000
    loose_performance_schema_max_table_instances=1000
  6. Submit the parameter modifications.

    Warning

    Modifying these parameters requires a database instance restart. We recommend performing this operation during off-peak hours and ensuring that your application has a reconnection mechanism.

    After the parameters are modified, you can run the SHOW GLOBAL VARIABLES LIKE'%performance_schema'; command to check the status of the performance_schema parameter.