Keine Cache-Version

Caching deaktiviert Standardeinstellung für diese Seite:aktiviert (code DEF204)
Wenn die Anzeige zu langsam ist, können Sie den Benutzermodus deaktivieren, um die zwischengespeicherte Version anzuzeigen.

Rechercher dans le manuel MySQL

12.22 Performance Schema Functions

As of MySQL 8.0.16, MySQL includes built-in SQL functions that format or retrieve Performance Schema data, and that may be used as equivalents for the corresponding sys schema stored functions. The built-in functions can be invoked in any schema and require no qualifier, unlike the sys functions, which require either a sys. schema qualifier or that sys be the current schema.

Table 12.28 Performance Schema Functions

Name Description
FORMAT_BYTES() Convert byte count to value with units
FORMAT_PICO_TIME() Convert time in picoseconds to value with units
PS_CURRENT_THREAD_ID() Performance Schema thread ID for current thread
PS_THREAD_ID() Performance Schema thread ID for given thread

The built-in functions supersede the corresponding sys functions, which are deprecated and will be removed in a future MySQL version. Applications that use the sys functions should be adjusted to use the built-in functions instead, keeping in mind some minor differences between the sys functions and the built-in functions. For details about these differences, see the function descriptions in this section.

  • FORMAT_BYTES(count)

    Given a numeric byte count, converts it to human-readable format and returns a string consisting of a value and a units indicator. The string contains the number of bytes rounded to 2 decimal places and a minimum of 3 significant digits. Numbers less than 1024 bytes are represented as whole numbers and are not rounded.

    The units indicator depends on the size of the byte-count argument as shown in the following table.

    Argument Value Result Units Result Units Indicator
    Up to 1023 bytes bytes
    Up to 10242 − 1 kibibytes KiB
    Up to 10243 − 1 mebibytes MiB
    Up to 10244 − 1 gibibytes GiB
    Up to 10245 − 1 tebibytes TiB
    Up to 10246 − 1 pebibytes PiB
    10246 and up exbibytes EiB
    1. mysql> SELECT FORMAT_BYTES(512), FORMAT_BYTES(18446644073709551615);
    2. +-------------------+------------------------------------+
    3. | FORMAT_BYTES(512) | FORMAT_BYTES(18446644073709551615) |
    4. +-------------------+------------------------------------+
    5. |  512 bytes        | 16.00 EiB                          |
    6. +-------------------+------------------------------------+

    FORMAT_BYTES() was added in MySQL 8.0.16. It may be used instead of the sys schema format_bytes() function, keeping in mind this difference:

  • FORMAT_PICO_TIME(time_val)

    Given a numeric Performance Schema latency or wait time in picoseconds, converts it to human-readable format and returns a string consisting of a value and a units indicator. The string contains the decimal time rounded to 2 decimal places and a minimum of 3 significant digits. Times under 1 nanosecond are represented as whole numbers and are not rounded.

    The units indicator depends on the size of the time-value argument as shown in the following table.

    Argument Value Result Units Result Units Indicator
    Up to 103 − 1 picoseconds ps
    Up to 106 − 1 nanoseconds ns
    Up to 109 − 1 microseconds us
    Up to 1012 − 1 milliseconds ms
    Up to 60×1012 − 1 seconds s
    Up to 3.6×1015 − 1 minutes min
    Up to 8.64×1016 − 1 hours h
    8.64×1016 and up days d
    1. mysql> SELECT FORMAT_PICO_TIME(3501), FORMAT_PICO_TIME(188732396662000);
    2. +------------------------+-----------------------------------+
    3. | FORMAT_PICO_TIME(3501) | FORMAT_PICO_TIME(188732396662000) |
    4. +------------------------+-----------------------------------+
    5. | 3.50 ns                | 3.15 min                          |
    6. +------------------------+-----------------------------------+

    FORMAT_PICO_TIME() was added in MySQL 8.0.16. It may be used instead of the sys schema format_time() function, keeping in mind these differences:

  • PS_CURRENT_THREAD_ID()

    Returns a BIGINT UNSIGNED value representing the Performance Schema thread ID assigned to the current connection.

    The thread ID return value is a value of the type given in the THREAD_ID column of Performance Schema tables.

    Performance Schema configuration affects PS_CURRENT_THREAD_ID() the same way as for PS_THREAD_ID(). For details, see the description of that function.

    1. mysql> SELECT PS_CURRENT_THREAD_ID();
    2. +------------------------+
    3. | PS_CURRENT_THREAD_ID() |
    4. +------------------------+
    5. |                     52 |
    6. +------------------------+
    7. mysql> SELECT PS_THREAD_ID(CONNECTION_ID());
    8. +-------------------------------+
    9. | PS_THREAD_ID(CONNECTION_ID()) |
    10. +-------------------------------+
    11. |                            52 |
    12. +-------------------------------+

    PS_CURRENT_THREAD_ID() was added in MySQL 8.0.16. It may be used as a shortcut for invoking the sys schema ps_thread_id() function with an argument of NULL or CONNECTION_ID().

  • PS_THREAD_ID(connection_id)

    Given a connection ID, returns a BIGINT UNSIGNED value representing the Performance Schema thread ID assigned to the connection ID, or NULL if no thread ID exists for the connection ID. The latter can occur for threads that are not instrumented.

    The connection ID argument is a value of the type given in the PROCESSLIST_ID column of the Performance Schema threads table or the Id column of SHOW PROCESSLIST output.

    The thread ID return value is a value of the type given in the THREAD_ID column of Performance Schema tables.

    Performance Schema configuration affects PS_THREAD_ID() operation as follows. (These remarks also apply to PS_CURRENT_THREAD_ID().)

    1. mysql> SELECT PS_THREAD_ID(6);
    2. +-----------------+
    3. | PS_THREAD_ID(6) |
    4. +-----------------+
    5. |              45 |
    6. +-----------------+

    PS_THREAD_ID() was added in MySQL 8.0.16. It may be used instead of the sys schema ps_thread_id() function, keeping in mind this difference:


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-performance-schema-functions.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