Commit 1c6f78e3 authored by Annamalai Gurusami's avatar Annamalai Gurusami

Bug #13113026 INFORMATION_SCHEMA.INNODB_BUFFER_PAGE_LRUFROM 5.6 BACKPORT

Backporting the WL#5716, "Information schema table for InnoDB
buffer pool information". Backporting revisions 2876.244.113,
2876.244.102 from mysql-trunk.

rb://1177 approved by Jimmy Yang. 
parent 7baba644
......@@ -863,6 +863,8 @@ TABLES TABLE_NAME select
TABLE_CONSTRAINTS TABLE_NAME select
TABLE_PRIVILEGES TABLE_NAME select
VIEWS TABLE_NAME select
INNODB_BUFFER_PAGE TABLE_NAME select
INNODB_BUFFER_PAGE_LRU TABLE_NAME select
delete from mysql.user where user='mysqltest_4';
delete from mysql.db where user='mysqltest_4';
flush privileges;
......
......@@ -109,13 +109,16 @@ Database: information_schema
| TRIGGERS |
| USER_PRIVILEGES |
| VIEWS |
| INNODB_CMP_RESET |
| INNODB_BUFFER_PAGE |
| INNODB_TRX |
| INNODB_CMPMEM_RESET |
| INNODB_BUFFER_POOL_STATS |
| INNODB_LOCK_WAITS |
| INNODB_CMPMEM |
| INNODB_CMP |
| INNODB_LOCKS |
| INNODB_CMPMEM_RESET |
| INNODB_CMP_RESET |
| INNODB_BUFFER_PAGE_LRU |
+---------------------------------------+
Database: INFORMATION_SCHEMA
+---------------------------------------+
......@@ -151,13 +154,16 @@ Database: INFORMATION_SCHEMA
| TRIGGERS |
| USER_PRIVILEGES |
| VIEWS |
| INNODB_CMP_RESET |
| INNODB_BUFFER_PAGE |
| INNODB_TRX |
| INNODB_CMPMEM_RESET |
| INNODB_BUFFER_POOL_STATS |
| INNODB_LOCK_WAITS |
| INNODB_CMPMEM |
| INNODB_CMP |
| INNODB_LOCKS |
| INNODB_CMPMEM_RESET |
| INNODB_CMP_RESET |
| INNODB_BUFFER_PAGE_LRU |
+---------------------------------------+
Wildcard: inf_rmation_schema
+--------------------+
......
SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS;
SELECT count(*) FROM INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS;
SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE;
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE;
CREATE TABLE infoschema_buffer_test (col1 INT) ENGINE = INNODB;
INSERT INTO infoschema_buffer_test VALUES(9);
SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
WHERE TABLE_NAME like "%infoschema_buffer_test"
and PAGE_STATE="file_page" and PAGE_TYPE="index";
TABLE_NAME INDEX_NAME NUMBER_RECORDS DATA_SIZE PAGE_STATE PAGE_TYPE
test/infoschema_buffer_test GEN_CLUST_INDEX 1 29 FILE_PAGE INDEX
INSERT INTO infoschema_buffer_test VALUES(19);
SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
WHERE TABLE_NAME like "%infoschema_buffer_test"
and PAGE_STATE="file_page" and PAGE_TYPE="index";
TABLE_NAME INDEX_NAME NUMBER_RECORDS DATA_SIZE PAGE_STATE PAGE_TYPE
test/infoschema_buffer_test GEN_CLUST_INDEX 2 58 FILE_PAGE INDEX
CREATE INDEX idx ON infoschema_buffer_test(col1);
SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
WHERE TABLE_NAME like "%infoschema_buffer_test"
and PAGE_STATE="file_page" and INDEX_NAME = "idx" and PAGE_TYPE="index";
TABLE_NAME INDEX_NAME NUMBER_RECORDS DATA_SIZE PAGE_STATE PAGE_TYPE
test/infoschema_buffer_test idx 2 32 FILE_PAGE INDEX
DROP TABLE infoschema_buffer_test;
SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
WHERE TABLE_NAME like "%infoschema_buffer_test";
TABLE_NAME INDEX_NAME NUMBER_RECORDS DATA_SIZE PAGE_STATE PAGE_TYPE
CREATE TABLE infoschema_parent (id INT NOT NULL, PRIMARY KEY (id))
ENGINE=INNODB;
CREATE TABLE infoschema_child (id INT, parent_id INT, INDEX par_ind (parent_id),
FOREIGN KEY (parent_id)
REFERENCES infoschema_parent(id)
ON DELETE CASCADE)
ENGINE=INNODB;
SELECT count(*)
FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
WHERE TABLE_NAME like "%infoschema_child" and PAGE_STATE="file_page"
and PAGE_TYPE="index";
count(*)
2
DROP TABLE infoschema_child;
DROP TABLE infoschema_parent;
show create table information_schema.innodb_buffer_page;
Table Create Table
INNODB_BUFFER_PAGE CREATE TEMPORARY TABLE `INNODB_BUFFER_PAGE` (
`POOL_ID` bigint(21) unsigned NOT NULL DEFAULT '0',
`BLOCK_ID` bigint(21) unsigned NOT NULL DEFAULT '0',
`SPACE` bigint(21) unsigned NOT NULL DEFAULT '0',
`PAGE_NUMBER` bigint(21) unsigned NOT NULL DEFAULT '0',
`PAGE_TYPE` varchar(64) DEFAULT NULL,
`FLUSH_TYPE` bigint(21) unsigned NOT NULL DEFAULT '0',
`FIX_COUNT` bigint(21) unsigned NOT NULL DEFAULT '0',
`IS_HASHED` varchar(3) DEFAULT NULL,
`NEWEST_MODIFICATION` bigint(21) unsigned NOT NULL DEFAULT '0',
`OLDEST_MODIFICATION` bigint(21) unsigned NOT NULL DEFAULT '0',
`ACCESS_TIME` bigint(21) unsigned NOT NULL DEFAULT '0',
`TABLE_NAME` varchar(1024) DEFAULT NULL,
`INDEX_NAME` varchar(1024) DEFAULT NULL,
`NUMBER_RECORDS` bigint(21) unsigned NOT NULL DEFAULT '0',
`DATA_SIZE` bigint(21) unsigned NOT NULL DEFAULT '0',
`COMPRESSED_SIZE` bigint(21) unsigned NOT NULL DEFAULT '0',
`PAGE_STATE` varchar(64) DEFAULT NULL,
`IO_FIX` varchar(64) DEFAULT NULL,
`IS_OLD` varchar(3) DEFAULT NULL,
`FREE_PAGE_CLOCK` bigint(21) unsigned NOT NULL DEFAULT '0'
) ENGINE=MEMORY DEFAULT CHARSET=utf8
show create table information_schema.innodb_buffer_page_lru;
Table Create Table
INNODB_BUFFER_PAGE_LRU CREATE TEMPORARY TABLE `INNODB_BUFFER_PAGE_LRU` (
`POOL_ID` bigint(21) unsigned NOT NULL DEFAULT '0',
`LRU_POSITION` bigint(21) unsigned NOT NULL DEFAULT '0',
`SPACE` bigint(21) unsigned NOT NULL DEFAULT '0',
`PAGE_NUMBER` bigint(21) unsigned NOT NULL DEFAULT '0',
`PAGE_TYPE` varchar(64) DEFAULT NULL,
`FLUSH_TYPE` bigint(21) unsigned NOT NULL DEFAULT '0',
`FIX_COUNT` bigint(21) unsigned NOT NULL DEFAULT '0',
`IS_HASHED` varchar(3) DEFAULT NULL,
`NEWEST_MODIFICATION` bigint(21) unsigned NOT NULL DEFAULT '0',
`OLDEST_MODIFICATION` bigint(21) unsigned NOT NULL DEFAULT '0',
`ACCESS_TIME` bigint(21) unsigned NOT NULL DEFAULT '0',
`TABLE_NAME` varchar(1024) DEFAULT NULL,
`INDEX_NAME` varchar(1024) DEFAULT NULL,
`NUMBER_RECORDS` bigint(21) unsigned NOT NULL DEFAULT '0',
`DATA_SIZE` bigint(21) unsigned NOT NULL DEFAULT '0',
`COMPRESSED_SIZE` bigint(21) unsigned NOT NULL DEFAULT '0',
`COMPRESSED` varchar(3) DEFAULT NULL,
`IO_FIX` varchar(64) DEFAULT NULL,
`IS_OLD` varchar(3) DEFAULT NULL,
`FREE_PAGE_CLOCK` bigint(21) unsigned NOT NULL DEFAULT '0'
) ENGINE=MEMORY DEFAULT CHARSET=utf8
show create table information_schema.innodb_buffer_pool_stats;
Table Create Table
INNODB_BUFFER_POOL_STATS CREATE TEMPORARY TABLE `INNODB_BUFFER_POOL_STATS` (
`POOL_ID` bigint(21) unsigned NOT NULL DEFAULT '0',
`POOL_SIZE` bigint(21) unsigned NOT NULL DEFAULT '0',
`FREE_BUFFERS` bigint(21) unsigned NOT NULL DEFAULT '0',
`DATABASE_PAGES` bigint(21) unsigned NOT NULL DEFAULT '0',
`OLD_DATABASE_PAGES` bigint(21) unsigned NOT NULL DEFAULT '0',
`MODIFIED_DATABASE_PAGES` bigint(21) unsigned NOT NULL DEFAULT '0',
`PENDING_DECOMPRESS` bigint(21) unsigned NOT NULL DEFAULT '0',
`PENDING_READS` bigint(21) unsigned NOT NULL DEFAULT '0',
`PENDING_FLUSH_LRU` bigint(21) unsigned NOT NULL DEFAULT '0',
`PENDING_FLUSH_LIST` bigint(21) unsigned NOT NULL DEFAULT '0',
`PAGES_MADE_YOUNG` bigint(21) unsigned NOT NULL DEFAULT '0',
`PAGES_NOT_MADE_YOUNG` bigint(21) unsigned NOT NULL DEFAULT '0',
`PAGES_MADE_YOUNG_RATE` double NOT NULL DEFAULT '0',
`PAGES_MADE_NOT_YOUNG_RATE` double NOT NULL DEFAULT '0',
`NUMBER_PAGES_READ` bigint(21) unsigned NOT NULL DEFAULT '0',
`NUMBER_PAGES_CREATED` bigint(21) unsigned NOT NULL DEFAULT '0',
`NUMBER_PAGES_WRITTEN` bigint(21) unsigned NOT NULL DEFAULT '0',
`PAGES_READ_RATE` double NOT NULL DEFAULT '0',
`PAGES_CREATE_RATE` double NOT NULL DEFAULT '0',
`PAGES_WRITTEN_RATE` double NOT NULL DEFAULT '0',
`NUMBER_PAGES_GET` bigint(21) unsigned NOT NULL DEFAULT '0',
`HIT_RATE` bigint(21) unsigned NOT NULL DEFAULT '0',
`YOUNG_MAKE_PER_THOUSAND_GETS` bigint(21) unsigned NOT NULL DEFAULT '0',
`NOT_YOUNG_MAKE_PER_THOUSAND_GETS` bigint(21) unsigned NOT NULL DEFAULT '0',
`NUMBER_PAGES_READ_AHEAD` bigint(21) unsigned NOT NULL DEFAULT '0',
`NUMBER_READ_AHEAD_EVICTED` bigint(21) unsigned NOT NULL DEFAULT '0',
`READ_AHEAD_RATE` double NOT NULL DEFAULT '0',
`READ_AHEAD_EVICTED_RATE` double NOT NULL DEFAULT '0',
`LRU_IO_TOTAL` bigint(21) unsigned NOT NULL DEFAULT '0',
`LRU_IO_CURRENT` bigint(21) unsigned NOT NULL DEFAULT '0',
`UNCOMPRESS_TOTAL` bigint(21) unsigned NOT NULL DEFAULT '0',
`UNCOMPRESS_CURRENT` bigint(21) unsigned NOT NULL DEFAULT '0'
) ENGINE=MEMORY DEFAULT CHARSET=utf8
# Exercise the code path for INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS
# and INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
-- source include/have_innodb.inc
-- disable_result_log
SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS;
# How many buffer pools we have
SELECT count(*) FROM INFORMATION_SCHEMA.INNODB_BUFFER_POOL_STATS;
SELECT * FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE;
# This gives the over all buffer pool size
SELECT COUNT(*) FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE;
-- enable_result_log
# Create a table and check its page info behave correctly in the pool
CREATE TABLE infoschema_buffer_test (col1 INT) ENGINE = INNODB;
INSERT INTO infoschema_buffer_test VALUES(9);
# We should be able to see this table in the buffer pool if we check
# right away
SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
WHERE TABLE_NAME like "%infoschema_buffer_test"
and PAGE_STATE="file_page" and PAGE_TYPE="index";
# The NUMBER_RECORDS and DATA_SIZE should check with each insertion
INSERT INTO infoschema_buffer_test VALUES(19);
SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
WHERE TABLE_NAME like "%infoschema_buffer_test"
and PAGE_STATE="file_page" and PAGE_TYPE="index";
CREATE INDEX idx ON infoschema_buffer_test(col1);
SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
WHERE TABLE_NAME like "%infoschema_buffer_test"
and PAGE_STATE="file_page" and INDEX_NAME = "idx" and PAGE_TYPE="index";
# Check the buffer after dropping the table
DROP TABLE infoschema_buffer_test;
SELECT TABLE_NAME, INDEX_NAME, NUMBER_RECORDS, DATA_SIZE, PAGE_STATE, PAGE_TYPE
FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
WHERE TABLE_NAME like "%infoschema_buffer_test";
# Do one more test
#--replace_regex /'*[0-9]*'/'NUM'/
CREATE TABLE infoschema_parent (id INT NOT NULL, PRIMARY KEY (id))
ENGINE=INNODB;
CREATE TABLE infoschema_child (id INT, parent_id INT, INDEX par_ind (parent_id),
FOREIGN KEY (parent_id)
REFERENCES infoschema_parent(id)
ON DELETE CASCADE)
ENGINE=INNODB;
SELECT count(*)
FROM INFORMATION_SCHEMA.INNODB_BUFFER_PAGE
WHERE TABLE_NAME like "%infoschema_child" and PAGE_STATE="file_page"
and PAGE_TYPE="index";
DROP TABLE infoschema_child;
DROP TABLE infoschema_parent;
show create table information_schema.innodb_buffer_page;
show create table information_schema.innodb_buffer_page_lru;
show create table information_schema.innodb_buffer_pool_stats;
......@@ -294,14 +294,7 @@ be effective only if PFS_GROUP_BUFFER_SYNC is defined. */
# endif /* !PFS_SKIP_BUFFER_MUTEX_RWLOCK */
#endif /* UNIV_PFS_MUTEX || UNIV_PFS_RWLOCK */
/** A chunk of buffers. The buffer pool is allocated in chunks. */
struct buf_chunk_struct{
ulint mem_size; /*!< allocated size of the chunk */
ulint size; /*!< size of frames[] and blocks[] */
void* mem; /*!< pointer to the memory area which
was allocated for the frames */
buf_block_t* blocks; /*!< array of buffer control blocks */
};
/********************************************************************//**
Gets the smallest oldest_modification lsn for any page in the pool. Returns
......@@ -4424,7 +4417,7 @@ buf_stats_aggregate_pool_info(
Collect buffer pool stats information for a buffer pool. Also
record aggregated stats if there are more than one buffer pool
in the server */
static
UNIV_INTERN
void
buf_stats_get_pool_info(
/*====================*/
......
......@@ -11767,7 +11767,10 @@ i_s_innodb_lock_waits,
i_s_innodb_cmp,
i_s_innodb_cmp_reset,
i_s_innodb_cmpmem,
i_s_innodb_cmpmem_reset
i_s_innodb_cmpmem_reset,
i_s_innodb_buffer_page,
i_s_innodb_buffer_page_lru,
i_s_innodb_buffer_stats
mysql_declare_plugin_end;
/** @brief Initialize the default value of innodb_commit_concurrency.
......
This diff is collapsed.
......@@ -35,5 +35,8 @@ extern struct st_mysql_plugin i_s_innodb_cmp;
extern struct st_mysql_plugin i_s_innodb_cmp_reset;
extern struct st_mysql_plugin i_s_innodb_cmpmem;
extern struct st_mysql_plugin i_s_innodb_cmpmem_reset;
extern struct st_mysql_plugin i_s_innodb_buffer_page;
extern struct st_mysql_plugin i_s_innodb_buffer_page_lru;
extern struct st_mysql_plugin i_s_innodb_buffer_stats;;
#endif /* i_s_h */
......@@ -68,7 +68,10 @@ Created 11/5/1995 Heikki Tuuri
position of the block. */
/* @} */
#define MAX_BUFFER_POOLS 64 /*!< The maximum number of buffer
#define MAX_BUFFER_POOLS_BITS 6 /*!< Number of bits to representing
a buffer pool ID */
#define MAX_BUFFER_POOLS (1 << MAX_BUFFER_POOLS_BITS)
/*!< The maximum number of buffer
pools that can be defined */
#define BUF_POOL_WATCH_SIZE 1 /*!< Maximum number of concurrent
......@@ -758,6 +761,18 @@ void
buf_print_io(
/*=========*/
FILE* file); /*!< in: file where to print */
/*******************************************************************//**
Collect buffer pool stats information for a buffer pool. Also
record aggregated stats if there are more than one buffer pool
in the server */
UNIV_INTERN
void
buf_stats_get_pool_info(
/*====================*/
buf_pool_t* buf_pool, /*!< in: buffer pool */
ulint pool_id, /*!< in: buffer pool ID */
buf_pool_info_t* all_pool_info); /*!< in/out: buffer pool info
to fill */
/*********************************************************************//**
Returns the ratio in percents of modified pages in the buffer pool /
database pages in the buffer pool.
......@@ -1325,12 +1340,25 @@ void
buf_get_total_stat(
/*===============*/
buf_pool_stat_t*tot_stat); /*!< out: buffer pool stats */
/*********************************************************************//**
Get the nth chunk's buffer block in the specified buffer pool.
@return the nth chunk's buffer block. */
UNIV_INLINE
buf_block_t*
buf_get_nth_chunk_block(
/*====================*/
const buf_pool_t* buf_pool, /*!< in: buffer pool instance */
ulint n, /*!< in: nth chunk in the buffer pool */
ulint* chunk_size); /*!< in: chunk size */
#endif /* !UNIV_HOTBACKUP */
/** The common buffer control block structure
for compressed and uncompressed frames */
/** Number of bits used for buffer page states. */
#define BUF_PAGE_STATE_BITS 3
struct buf_page_struct{
/** @name General fields
None of these bit-fields must be modified without holding
......@@ -1345,7 +1373,8 @@ struct buf_page_struct{
unsigned offset:32; /*!< page number; also protected
by buf_pool->mutex. */
unsigned state:3; /*!< state of the control block; also
unsigned state:BUF_PAGE_STATE_BITS;
/*!< state of the control block; also
protected by buf_pool->mutex.
State transitions from
BUF_BLOCK_READY_FOR_USE to
......
......@@ -36,6 +36,15 @@ Created 11/5/1995 Heikki Tuuri
#include "buf0lru.h"
#include "buf0rea.h"
/** A chunk of buffers. The buffer pool is allocated in chunks. */
struct buf_chunk_struct{
ulint mem_size; /*!< allocated size of the chunk */
ulint size; /*!< size of frames[] and blocks[] */
void* mem; /*!< pointer to the memory area which
was allocated for the frames */
buf_block_t* blocks; /*!< array of buffer control blocks */
};
/*********************************************************************//**
Gets the current size of buffer buf_pool in bytes.
@return size in bytes */
......@@ -1276,4 +1285,21 @@ buf_pool_mutex_exit_all(void)
buf_pool_mutex_exit(buf_pool);
}
}
/*********************************************************************//**
Get the nth chunk's buffer block in the specified buffer pool.
@return the nth chunk's buffer block. */
UNIV_INLINE
buf_block_t*
buf_get_nth_chunk_block(
/*====================*/
const buf_pool_t* buf_pool, /*!< in: buffer pool instance */
ulint n, /*!< in: nth chunk in the buffer pool */
ulint* chunk_size) /*!< in: chunk size */
{
const buf_chunk_t* chunk;
chunk = buf_pool->chunks + n;
*chunk_size = chunk->size;
return(chunk->blocks);
}
#endif /* !UNIV_HOTBACKUP */
......@@ -142,6 +142,8 @@ extern fil_addr_t fil_addr_null;
#define FIL_PAGE_TYPE_BLOB 10 /*!< Uncompressed BLOB page */
#define FIL_PAGE_TYPE_ZBLOB 11 /*!< First compressed BLOB page */
#define FIL_PAGE_TYPE_ZBLOB2 12 /*!< Subsequent compressed BLOB page */
#define FIL_PAGE_TYPE_LAST FIL_PAGE_TYPE_ZBLOB2
/*!< Last page type */
/* @} */
/** Space types @{ */
......
......@@ -41,6 +41,9 @@ Created 12/9/1995 Heikki Tuuri
#include "sync0rw.h"
#endif /* !UNIV_HOTBACKUP */
/* Type used for all log sequence number storage and arithmetics */
typedef ib_uint64_t lsn_t;
/** Redo log buffer */
typedef struct log_struct log_t;
/** Redo log group */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment