Geen cache-versie.

Caching uitgeschakeld. Standaardinstelling voor deze pagina:ingeschakeld (code DEF204)
Als het scherm te langzaam is, kunt u de gebruikersmodus uitschakelen om de cacheversie te bekijken.

Rechercher dans le manuel MySQL

27.4.4.25 The statement _performance _analyzer () Procedure

Creates a report of the statements running on the server. The views are calculated based on the overall and/or delta activity.

This procedure disables binary logging during its execution by manipulating the session value of the sql_log_bin system variable. That is a restricted operation, so the procedure requires privileges sufficient to set restricted session variables. See Section 5.1.9.1, “System Variable Privileges”.

Parameters
  • in_action ENUM('snapshot', 'overall', 'delta', 'create_tmp', 'create_table', 'save', 'cleanup'): The action to take. These values are permitted:

    • snapshot: Store a snapshot. The default is to make a snapshot of the current content of the Performance Schema events_statements_summary_by_digest table. By setting in_table, this can be overwritten to copy the content of the specified table. The snapshot is stored in the sys schema tmp_digests temporary table.

    • overall: Generate an analysis based on the content of the table specified by in_table. For the overall analysis, in_table can be NOW() to use a fresh snapshot. This overwrites an existing snapshot. Use NULL for in_table to use the existing snapshot. If in_table is NULL and no snapshot exists, a new snapshot is created. The in_views parameter and the statement_performance_analyzer.limit configuration option affect the operation of this procedure.

    • delta: Generate a delta analysis. The delta is calculated between the reference table specified by in_table and the snapshot, which must exist. This action uses the sys schema tmp_digests_delta temporary table. The in_views parameter and the statement_performance_analyzer.limit configuration option affect the operation of this procedure.

    • create_table: Create a regular table suitable for storing the snapshot for later use (for example, for calculating deltas).

    • create_tmp: Create a temporary table suitable for storing the snapshot for later use (for example, for calculating deltas).

    • save: Save the snapshot in the table specified by in_table. The table must exist and have the correct structure. If no snapshot exists, a new snapshot is created.

    • cleanup: Remove the temporary tables used for the snapshot and delta.

  • in_table VARCHAR(129): The table parameter used for some of the actions specified by the in_action parameter. Use the format db_name.tbl_name or tbl_name without using any backtick (`) identifier-quoting characters. Periods (.) are not supported in database and table names.

    The meaning of the in_table value for each in_action value is detailed in the individual in_action value descriptions.

  • in_views SET ('with_runtimes_in_95th_percentile', 'analysis', 'with_errors_or_warnings', 'with_full_table_scans', 'with_sorting', 'with_temp_tables', 'custom'): Which views to include. This parameter is a SET value, so it can contain multiple view names, separated by commas. The default is to include all views except custom. The following values are permitted:

Inhoudsopgave Haut

Configuration Options

statement_performance_analyzer() operation can be modified using the following configuration options or their corresponding user-defined variables (see Section 27.4.2.1, “The sys_config Table”):

  • debug, @sys.debug

    If this option is ON, produce debugging output. The default is OFF.

  • statement_performance_analyzer.limit, @sys.statement_performance_analyzer.limit

    The maximum number of rows to return for views that have no built-in limit. The default is 100.

  • statement_performance_analyzer.view, @sys.statement_performance_analyzer.view

    The custom query or view to be used. If the option value contains a space, it is interpreted as a query. Otherwise, it must be the name of an existing view that queries the Performance Schema events_statements_summary_by_digest table. There cannot be any LIMIT clause in the query or view definition if the statement_performance_analyzer.limit configuration option is greater than 0. If specifying a view, use the same format as for the in_table parameter. The default is NULL (no custom view defined).

To create a report with the queries in the 95th percentile since the last truncation of events_statements_summary_by_digest and with a one-minute delta period:

  1. Create a temporary table to store the initial snapshot.

  2. Create the initial snapshot.

  3. Save the initial snapshot in the temporary table.

  4. Wait one minute.

  5. Create a new snapshot.

  6. Perform analysis based on the new snapshot.

  7. Perform analysis based on the delta between the initial and new snapshots.

  1. mysql> CALL sys.statement_performance_analyzer('create_tmp', 'mydb.tmp_digests_ini', NULL);
  2. Query OK, 0 rows affected (0.08 sec)
  3.  
  4. mysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);
  5. Query OK, 0 rows affected (0.02 sec)
  6.  
  7. mysql> CALL sys.statement_performance_analyzer('save', 'mydb.tmp_digests_ini', NULL);
  8. Query OK, 0 rows affected (0.00 sec)
  9.  
  10. mysql> DO SLEEP(60);
  11. Query OK, 0 rows affected (1 min 0.00 sec)
  12.  
  13. mysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);
  14. Query OK, 0 rows affected (0.02 sec)
  15.  
  16. mysql> CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile');
  17. +-----------------------------------------+
  18. | Next Output                             |
  19. +-----------------------------------------+
  20. | Queries with Runtime in 95th Percentile |
  21. +-----------------------------------------+
  22. 1 row in set (0.05 sec)
  23.  
  24. ...
  25.  
  26. mysql> CALL sys.statement_performance_analyzer('delta', 'mydb.tmp_digests_ini', 'with_runtimes_in_95th_percentile');
  27. +-----------------------------------------+
  28. | Next Output                             |
  29. +-----------------------------------------+
  30. | Queries with Runtime in 95th Percentile |
  31. +-----------------------------------------+
  32. 1 row in set (0.03 sec)
  33.  
  34. ...

Create an overall report of the 95th percentile queries and the top 10 queries with full table scans:

  1. mysql> CALL sys.statement_performance_analyzer('snapshot', NULL, NULL);
  2. Query OK, 0 rows affected (0.01 sec)                                
  3.  
  4. mysql> SET @sys.statement_performance_analyzer.limit = 10;
  5. Query OK, 0 rows affected (0.00 sec)        
  6.  
  7. mysql> CALL sys.statement_performance_analyzer('overall', NULL, 'with_runtimes_in_95th_percentile,with_full_table_scans');
  8. +-----------------------------------------+
  9. | Next Output                             |
  10. +-----------------------------------------+
  11. | Queries with Runtime in 95th Percentile |
  12. +-----------------------------------------+
  13. 1 row in set (0.01 sec)
  14.  
  15. ...
  16.  
  17. +-------------------------------------+
  18. | Next Output                         |
  19. +-------------------------------------+
  20. | Top 10 Queries with Full Table Scan |
  21. +-------------------------------------+
  22. 1 row in set (0.09 sec)
  23.  
  24. ...

Use a custom view showing the top 10 queries sorted by total execution time, refreshing the view every minute using the watch command in Linux:

  1. mysql> CREATE OR REPLACE VIEW mydb.my_statements AS
  2.        SELECT sys.format_statement(DIGEST_TEXT) AS query,
  3.               SCHEMA_NAME AS db,
  4.               COUNT_STAR AS exec_count,
  5.               sys.format_time(SUM_TIMER_WAIT) AS total_latency,
  6.               sys.format_time(AVG_TIMER_WAIT) AS avg_latency,
  7.               ROUND(IFNULL(SUM_ROWS_SENT / NULLIF(COUNT_STAR, 0), 0)) AS rows_sent_avg,
  8.               ROUND(IFNULL(SUM_ROWS_EXAMINED / NULLIF(COUNT_STAR, 0), 0)) AS rows_examined_avg,
  9.               ROUND(IFNULL(SUM_ROWS_AFFECTED / NULLIF(COUNT_STAR, 0), 0)) AS rows_affected_avg,
  10.               DIGEST AS digest
  11.          FROM performance_schema.events_statements_summary_by_digest
  12.        ORDER BY SUM_TIMER_WAIT DESC;
  13. Query OK, 0 rows affected (0.10 sec)
  14.  
  15. mysql> CALL sys.statement_performance_analyzer('create_table', 'mydb.digests_prev', NULL);
  16. Query OK, 0 rows affected (0.10 sec)
  17.  
  18. shell> watch -n 60 "mysql sys --table -e \"
  19. > SET @sys.statement_performance_analyzer.view = 'mydb.my_statements';
  20. > SET @sys.statement_performance_analyzer.limit = 10;
  21. > CALL statement_performance_analyzer('snapshot', NULL, NULL);
  22. > CALL statement_performance_analyzer('delta', 'mydb.digests_prev', 'custom');
  23. > CALL statement_performance_analyzer('save', 'mydb.digests_prev', NULL);
  24. > \""
  25.  
  26. Every 60.0s: mysql sys --table -e "        ...  Mon Dec 22 10:58:51 2014
  27.  
  28. +----------------------------------+
  29. | Next Output                      |
  30. +----------------------------------+
  31. | Top 10 Queries Using Custom View |
  32. +----------------------------------+
  33. +-------------------+-------+------------+---------------+-------------+---------------+-------------------+-------------------+----------------------------------+
  34. | query             | db    | exec_count | total_latency | avg_latency | rows_sent_avg | rows_examined_avg | rows_affected_avg | digest                           |
  35. +-------------------+-------+------------+---------------+-------------+---------------+-------------------+-------------------+----------------------------------+
  36. ...

Zoek in de MySQL-handleiding

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 26/06/2006 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/mysql-rf-sys-statement-performance-analyzer.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:en Manuel MySQL : https://dev.mysql.com/

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut