mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 02:30:06 +01:00
99bd226059
The new statistics is enabled by adding the "engine", "innodb" or "full" option to --log-slow-verbosity Example output: # Pages_accessed: 184 Pages_read: 95 Pages_updated: 0 Old_rows_read: 1 # Pages_read_time: 17.0204 Engine_time: 248.1297 Page_read_time is time doing physical reads inside a storage engine. (Writes cannot be tracked as these are usually done in the background). Engine_time is the time spent inside the storage engine for the full duration of the read/write/update calls. It uses the same code as 'analyze statement' for calculating the time spent. The engine statistics is done with a generic interface that should be easy for any engine to use. It can also easily be extended to provide even more statistics. Currently only InnoDB has counters for Pages_% and Undo_% status. Engine_time works for all engines. Implementation details: class ha_handler_stats holds all engine stats. This class is included in handler and THD classes. While a query is running, all statistics is updated in the handler. In close_thread_tables() the statistics is added to the THD. handler::handler_stats is a pointer to where statistics should be collected. This is set to point to handler::active_handler_stats if stats are requested. If not, it is set to 0. handler_stats has also an element, 'active' that is 1 if stats are requested. This is to allow engines to avoid doing any 'if's while updating the statistics. Cloned or partition tables have the pointer set to the base table if status are requested. There is a small performance impact when using --log-slow-verbosity=engine: - All engine calls in 'select' will be timed. - IO calls for InnoDB reads will be timed. - Incrementation of counters are done on local variables and accesses are inline, so these should have very little impact. - Statistics has to be reset for each statement for the THD and each used handler. This is only 40 bytes, which should be neglectable. - For partition tables we have to loop over all partitions to update the handler_status as part of table_init(). Can be optimized in the future to only do this is log-slow-verbosity changes. For this to work we have to update handler_status for all opened partitions and also for all partitions opened in the future. Other things: - Added options 'engine' and 'full' to log-slow-verbosity. - Some of the new files in the test suite comes from Percona server, which has similar status information. - buf_page_optimistic_get(): Do not increment any counter, since we are only validating a pointer, not performing any buf_pool.page_hash lookup. - Added THD argument to save_explain_data_intern(). - Switched arguments for save_explain_.*_data() to have always THD first (generates better code as other functions also have THD first).
60 lines
2.3 KiB
C
60 lines
2.3 KiB
C
/* Copyright (C) 2009, 2017, MariaDB Corporation.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 or later of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
|
|
|
|
/* Defining what to log to slow log */
|
|
|
|
#ifndef LOG_SLOW_INCLUDED
|
|
#define LOG_SLOW_INCLUDED
|
|
|
|
#define LOG_SLOW_VERBOSITY_INIT 0
|
|
#define LOG_SLOW_VERBOSITY_INNODB (1U << 0) /* Old option */
|
|
#define LOG_SLOW_VERBOSITY_QUERY_PLAN (1U << 1)
|
|
#define LOG_SLOW_VERBOSITY_EXPLAIN (1U << 2)
|
|
#define LOG_SLOW_VERBOSITY_STORAGE_ENGINE (1U << 3) /* Replaces InnoDB */
|
|
#define LOG_SLOW_VERBOSITY_FULL (1U << 4)
|
|
|
|
#define LOG_SLOW_VERBOSITY_ENGINE (LOG_SLOW_VERBOSITY_FULL | \
|
|
LOG_SLOW_VERBOSITY_INNODB | \
|
|
LOG_SLOW_VERBOSITY_STORAGE_ENGINE)
|
|
|
|
#define QPLAN_INIT QPLAN_QC_NO
|
|
|
|
#define QPLAN_ADMIN (1U << 0)
|
|
#define QPLAN_FILESORT (1U << 1)
|
|
#define QPLAN_FILESORT_DISK (1U << 2)
|
|
#define QPLAN_FILESORT_PRIORITY_QUEUE (1U << 3)
|
|
#define QPLAN_FULL_JOIN (1U << 4)
|
|
#define QPLAN_FULL_SCAN (1U << 5)
|
|
#define QPLAN_NOT_USING_INDEX (1U << 6)
|
|
#define QPLAN_QC (1U << 7)
|
|
#define QPLAN_QC_NO (1U << 8)
|
|
#define QPLAN_TMP_TABLE (1U << 9)
|
|
#define QPLAN_TMP_DISK (1U << 10)
|
|
|
|
/* ... */
|
|
#define QPLAN_STATUS (1UL << 31) /* not in the slow_log_filter */
|
|
#define QPLAN_MAX (1UL << 31) /* reserved as placeholder */
|
|
|
|
/* Bits for log_slow_disabled_statements */
|
|
#define LOG_SLOW_DISABLE_ADMIN (1 << 0)
|
|
#define LOG_SLOW_DISABLE_CALL (1 << 1)
|
|
#define LOG_SLOW_DISABLE_SLAVE (1 << 2)
|
|
#define LOG_SLOW_DISABLE_SP (1 << 3)
|
|
|
|
/* Bits for log_disabled_statements */
|
|
#define LOG_DISABLE_SLAVE (1 << 0)
|
|
#define LOG_DISABLE_SP (1 << 1)
|
|
|
|
#endif /* LOG_SLOW_INCLUDED */
|