Rechercher dans le manuel MySQL

26.12.6.4 The prepared_statements_instances Table

The Performance Schema provides instrumentation for prepared statements, for which there are two protocols:

  • The binary protocol. This is accessed through the MySQL C API and maps onto underlying server commands as shown in the following table.

    C API Function Corresponding Server Command
    mysql_stmt_prepare() COM_STMT_PREPARE
    mysql_stmt_execute() COM_STMT_EXECUTE
    mysql_stmt_close() COM_STMT_CLOSE
  • The text protocol. This is accessed using SQL statements and maps onto underlying server commands as shown in the following table.

    SQL Statement Corresponding Server Command
    PREPARE SQLCOM_PREPARE
    EXECUTE SQLCOM_EXECUTE
    DEALLOCATE PREPARE, DROP PREPARE SQLCOM_DEALLOCATE PREPARE

Performance Schema prepared statement instrumentation covers both protocols. The following discussion refers to the server commands rather than the C API functions or SQL statements.

Information about prepared statements is available in the prepared_statements_instances table. This table enables inspection of prepared statements used in the server and provides aggregated statistics about them. To control the size of this table, set the performance_schema_max_prepared_statements_instances system variable at server startup.

Collection of prepared statement information depends on the statement instruments shown in the following table. These instruments are enabled by default. To modify them, update the setup_instruments table.

Instrument Server Command
statement/com/Prepare COM_STMT_PREPARE
statement/com/Execute COM_STMT_EXECUTE
statement/sql/prepare_sql SQLCOM_PREPARE
statement/sql/execute_sql SQLCOM_EXECUTE

The Performance Schema manages the contents of the prepared_statements_instances table as follows:

  • Statement preparation

    A COM_STMT_PREPARE or SQLCOM_PREPARE command creates a prepared statement in the server. If the statement is successfully instrumented, a new row is added to the prepared_statements_instances table. If the statement cannot be instrumented, Performance_schema_prepared_statements_lost status variable is incremented.

  • Prepared statement execution

    Execution of a COM_STMT_EXECUTE or SQLCOM_PREPARE command for an instrumented prepared statement instance updates the corresponding prepared_statements_instances table row.

  • Prepared statement deallocation

    Execution of a COM_STMT_CLOSE or SQLCOM_DEALLOCATE_PREPARE command for an instrumented prepared statement instance removes the corresponding prepared_statements_instances table row. To avoid resource leaks, removal occurs even if the prepared statement instruments described previously are disabled.

The prepared_statements_instances table has these columns:

  • OBJECT_INSTANCE_BEGIN

    The address in memory of the instrumented prepared statement.

  • STATEMENT_ID

    The internal statement ID assigned by the server. The text and binary protocols both use statement IDs.

  • STATEMENT_NAME

    For the binary protocol, this column is NULL. For the text protocol, this column is the external statement name assigned by the user. For example, for the following SQL statement, the name of the prepared statement is stmt:

    1. PREPARE stmt FROM 'SELECT 1';
  • SQL_TEXT

    The prepared statement text, with ? placeholder markers.

  • OWNER_THREAD_ID, OWNER_EVENT_ID

    These columns indicate the event that created the prepared statement.

  • OWNER_OBJECT_TYPE, OWNER_OBJECT_SCHEMA, OWNER_OBJECT_NAME

    For a prepared statement created by a client session, these columns are NULL. For a prepared statement created by a stored program, these columns point to the stored program. A typical user error is forgetting to deallocate prepared statements. These columns can be used to find stored programs that leak prepared statements:

    1.   OWNER_OBJECT_TYPE, OWNER_OBJECT_SCHEMA, OWNER_OBJECT_NAME,
    2.   STATEMENT_NAME, SQL_TEXT
    3. FROM performance_schema.prepared_statements_instances
    4. WHERE OWNER_OBJECT_TYPE IS NOT NULL;
  • TIMER_PREPARE

    The time spent executing the statement preparation itself.

  • COUNT_REPREPARE

    The number of times the statement was reprepared internally (see Section 8.10.3, “Caching of Prepared Statements and Stored Programs”). Timing statistics for repreparation are not available because it is counted as part of statement execution, not as a separate operation.

  • COUNT_EXECUTE, SUM_TIMER_EXECUTE, MIN_TIMER_EXECUTE, AVG_TIMER_EXECUTE, MAX_TIMER_EXECUTE

    Aggregated statistics for executions of the prepared statement.

  • SUM_xxx

    The remaining SUM_xxx columns are the same as for the statement summary tables (see Section 26.12.17.3, “Statement Summary Tables”).

The prepared_statements_instances table has these indexes:

  • Primary key on (OBJECT_INSTANCE_BEGIN)

  • Index on (STATEMENT_ID)

  • Index on (STATEMENT_NAME)

  • Index on (OWNER_THREAD_ID, OWNER_EVENT_ID)

  • Index on (OWNER_OBJECT_TYPE, OWNER_OBJECT_SCHEMA, OWNER_OBJECT_NAME)

TRUNCATE TABLE resets the statistics columns of the prepared_statements_instances table.


Suchen Sie im MySQL-Handbuch

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 26/06/2006, zuletzt geändert 26/10/2018
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/mysql-rf-prepared-statements-instances-table.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:en Manuel MySQL : https://dev.mysql.com/

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.

Inhaltsverzeichnis Haut