Enable Logging of Slow Queries (Slow Query Log) in MySQL Database Attivare la registrazione di Slow query (query lente Accedi) nel Database MySQL
One of the main requirements for a fast Uno dei principali requisiti per un veloce web server Web server is to has efficient and effective SQL statements or queries that are optimized. è a è efficiente ed efficace istruzioni SQL o query che sono ottimizzati. Any non-optimal SQL (Structured Query Language) commands or statements that take too long or lengthy time to execute will use up a lot of system resources, causing Qualsiasi non ottimale di SQL (Structured Query Language) comandi o in dichiarazioni che prendono troppo lungo o lungo tempo per l'esecuzione di utilizzerà un sacco di risorse di sistema, causando MySQL database to run slower, and then more and more queries backlogs queuing up, and when connection limit is reached, visitors are been denied or refused connection. banca dati per l'esecuzione più lento, quindi più e più arretrati query fare la coda, e quando la connessione limite viene raggiunto, i visitatori sono stati negati o rifiutati di connessione. In worst case scenario, your web server will go down as well, or continuously underperform. Nella peggiore delle ipotesi, il tuo server web passerà oltre, oppure in modo continuo prestazioni. The case is especially true when you are using MyISAM table type which uses table-level locking instead of row-level locking in a high traffic website. Il caso è particolarmente vero quando si utilizzano tabelle MyISAM tipo che utilizza tabella a livello di blocco, invece di fila a livello di blocco in un sito web ad alto traffico.
Sometime, a single SQL query may be the cause of all the server’s problems. Qualche volta, una sola query SQL possono essere la causa di tutti i problemi del server. MySQL has built-in functionality to capture slow query log or identify queries that are not optimal and take a long time to finish, which allows you to log all slow running queries which took over defined number of seconds to execute by MySQL database engine to a file. MySQL è disponibile una funzionalità incorporata per catturare query lente di log o identificare le query che non sono ottimali e un lungo periodo di tempo per finire, che consente la registrazione di tutte le lenti uso di query che ha rilevato definito numero di secondi per l'esecuzione di database MySQL a un motore file. Slow query log is not activated or on by default MySQL installation, thus it is one of the less-used logs. Query lente di log non è attivato o per impostazione predefinita di installazione di MySQL, quindi è uno dei meno utilizzati log.
To enable slow query log, simply add the following line to MySQL configuration file (my.cnf or my.ini), and then restart the MySQL server: Al fine di consentire l'accesso query lente, basta aggiungere la seguente riga al file di configurazione di MySQL (my.cnf o my.ini), quindi riavviare il server MySQL:
log-slow-queries di log-slow-query
or o
log-slow-queries = [path to the log file] log-slow-query = [percorso del file di log]
Replace [path to the log file] with actual path to the slow query log file you want the MySQL to write the log to, which is the optional value. Sostituire [percorso del file di log] con l'effettivo percorso della query lente file di log che si desidera MySQL per scrivere il log, che è il valore opzionale.
Or you can start mysqld with with the –log-slow-queries[=file_name] option to enable the slow query log. O si può avviare con mysqld con il log-slow-query [= nome_file] opzione per abilitare la lentezza di log di query. In both syntaxes, if not log file name is specified, the default name is host_name -slow.log, stored in the MySQL data file directory. In entrambi i sintassi, se non il nome del file di log è specificata, il nome predefinito è host_name-slow.log, memorizzati nel file di dati di MySQL directory. If a filename is given, but not as an absolute pathname, the server writes the file in the data directory too. Se un nome di file è data, ma non come un percorso assoluto, il server scrive il file nella directory dei dati.
After enabling slow query log, MySQL will create, capture and log to the log file with all SQL statements that took more than long_query_time seconds to execute, which is by default set to 10 seconds. Dopo l'attivazione di query lente di log, MySQL creerà, la cattura e accedere ai file di log con tutti i istruzioni SQL che ha avuto più di long_query_time secondi per eseguire, che di default è impostato su 10 secondi. The time to acquire the initial table locks is not counted as execution time. Il tempo per acquisire le serrature tabella iniziale non è considerato come tempo di esecuzione. mysqld writes a statement to the slow query log after it has been executed and after all locks have been released, so log order might be different from execution order. mysqld scrive una dichiarazione alla query lente di log dopo che è stato eseguito e dopo tutti i blocchi sono stati liberati, per accedere in modo potrebbe essere diversa da ordine di esecuzione.
You can then examine all the SQL queries that took longer than the pre-defined number of seconds (10 seconds by default) in the host_name -slow.log, and then take the necessary steps to optimize the SQL statements. È quindi possibile esaminare tutte le query SQL che ha avuto più lungo del pre-definito numero di secondi (10 secondi per impostazione predefinita) nel host_name-slow.log, e quindi prendere le misure necessarie per ottimizzare le istruzioni SQL. The slow query log will tell you about what was time the query completed, how long the query took to run, how long it took to secure its locks, how many rows were sent back as a result, how many rows were examined to determine the result, which database was used, and the actual query itself. La query lente di log vi dirà su ciò che è stato il tempo di query completato, per quanto tempo la query ha preso a funzionare, la sua durata per garantire la sua serrature, quante righe sono state inviate nuovamente il risultato, quante righe sono state esaminate per determinare il risultato, che è stato utilizzato banca dati, e l'effettiva ricerca stessa. But bear in mind that a SQL query contained in the log may have already optimum, but executed slowly due to the system resources been used up by the actual slow statement that need to be fine tuned. Ma tenere presente che una query SQL contenute nel registro possono avere già ottimale, ma eseguito lentamente a causa delle risorse di sistema stati utilizzati dalla effettiva lento dichiarazione che devono essere sintonizzati ammenda.
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. IMPORTANTE: Questa è una pagina tradotta macchina che è fornito "così com'è" senza alcuna garanzia. Machine translation may be difficult to understand. Traduzione automatica può essere difficile da capire. Please refer to Si prega di fare riferimento a original English article articolo originale in lingua inglese whenever possible. quando possibile.
Share and contribute or get technical support and help at Condividere e contribuire o ottenere supporto tecnico e assistenza in My Digital Life Forums La mia vita digitale Forum .
Related Articles Articoli correlati
- Change or Set MySQL Long Query Time Value for log-slow-queries Modificare o impostare a lungo MySQL Query Time Rapporto di log-slow-query
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4 Installare server Web in Windows XP con Apache2, PHP5 e MySQL4 - Parte 4
- Change and Reset MySQL root Password Reset cambiamento e MySQL root Password
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Come fare il backup e ripristino (esportazione e importazione) basi di dati di MySQL Tutorial
- WordPress MySQL SQL Query Error in WPDB Class WordPress mysql query SQL errore nella classe WPDB
- You Are Not Authorized to Execute SQL Queries in vBulletin Maintenance Non siete autorizzati ad eseguire query SQL nella manutenzione vBulletin
- MySQL Database Performance Tuning Best Practices Video Tutorial MySQL database performance tuning migliori pratiche video tutorial
- Using PHP-MySQL Persistent Connections to Run WordPress Blog Utilizzo di PHP-MySQL le connessioni persistenti per eseguire blog di WordPress
- How to Read MySQL Binary Log Files (BinLog) with mysqlbinlog Come leggere MySQL Binary file di log (BinLog) con mysqlbinlog
- How to Bypass and Stop Automatic Logon to Log On as Different User Come By-pass e Stop l'accesso automatico di accedere come utente diverso









January 23rd, 2007 00:22 23 gennaio 2007 00:22
[...] If you enable slow queries log of MySQL database server, you will notice that from the slow query log file contains only SQL statements and queries that took more than query_time of 10 seconds to execute or run. [...] Se si attiva lento query log del server di database MySQL, si noterà che dalla query lente file di log contiene solo dichiarazioni di SQL e query che ha avuto più di query_time di 10 secondi per eseguire o correre. This is the default value or query time threshold for log_slow_queries function, which is 10 seconds. Questo è il valore di default o Query Time soglia per log_slow_queries funzione, che è di 10 secondi. 10 seconds is way too long for a SQL query to complete, so the value may be too high to capture any meaningful data. 10 secondi è troppo lungo per una query SQL per completare, in modo che il valore può essere troppo alto per catturare qualsiasi dati significativi. You can alter or change the slow query time to lower value or number of seconds. Si può alterare o modificare la query lente tempo di valore inferiore o del numero di secondi. You can set a new long_query_time in the MySQL configuration file, namely my.cnf or my.ini, normally located in /etc directory. È possibile impostare un nuovo long_query_time nel file di configurazione di MySQL, vale a my.cnf o my.ini, di solito situati in / etc directory. Simply add the following line to the configuration file: [...] Semplicemente aggiungere la seguente riga al file di configurazione: [...]