I’ve seen a number of solutions for finding long running transactions or sessions within InnoDB / MySQL now. Every single one of them has (in the past by necessity) been implemented as a script (other than one, more on that one later) that is either invoked manually, or via some cron job, that then connects and tries to find, and possibly diagnose or kill, transactions that break some “long …
[Read more]
Views in MySQL really has quite a bad reputation, for bad
performance mainly, but also there were some stability issues at
some point. Now they are pretty stable, but I don't see them used
that much. One place where I like to use them myself is in
combination with INFORMATION_SCHEMA tables. The I_S tables are
really useful and contain a lot of information, and by using
VIEWs we can massage the data a bit.
I often have a database specifcally for DBA needs, so that is
what we will use here.
CREATE DATABASE IF NOT EXISTS dba;
USE dba;
OK, now we have a database to play with. Lets solve a minor
problem first. Being able to use the TABLES table in
INFORMATION_SCHEMA is great, as it allows standard SQL filtering
and processing, in difference to the output from SHOW TABLES
(largely at least, some filtering is available in the SHOW
commands also of course). But the TABLES table contains the
tables in ALL …
Giuseppe has a great post about the Evolution of MySQL metadata, and I thought I’d have a look at what we have in Drizzle. It’s pretty easy to work out how many tables are in each schema, we just query the standard INFORMATION_SCHEMA.TABLES view:
drizzle> select table_schema,count(table_name) -> from information_schema.tables -> group by table_schema; +--------------------+-------------------+ | table_schema | count(table_name) | +--------------------+-------------------+ | DATA_DICTIONARY | 53 | | INFORMATION_SCHEMA | 20 | +--------------------+-------------------+ 2 rows in set (0 sec)
In Drizzle it’s important to note that there is a differentiation between SQL …
[Read more]
I was looking at the latest MySQL versions, and I happened to
notice that there has been a great increment in the number of
metadata tables, both in the information_schema and
performance_schema databases. So I made a simple count of both
schemas in the various versions, and draw a graph. The advance
looks straightforward.
version | Information_schema | performance_schema |
---|---|---|
5.0.92 | 17 | 0 |
5.1.54 | 28 | 0 |
5.1.54 with innodb plugin | 35 | 0 |
5.5.8 | 37 | 17 |
5.6.2 | 48 | …
The announcement of MySQL 5.5 released as GA has outlined the
improvements in this version, which indeed has enough good
new features to excite most any user. There are two additions, though, that were lost in the noise of the bigger features, and I would like to spend a few words for each of them. |
The first addition is something that users of stored routines
have been waiting for since MySQL 5.0. No, it is not SIGNAL and
its close associate RESIGNAL, which have been publicized enough.
I am talking about the stored routine parameters, for
which now there is a dedicated table in the
information_schema.
Let's see an example, with a simple …
You may have read a previous post of mine, back in April this
year, where I wrote about using the MySQL 5.5 Audit interface to
SQL Statement monitoring. There was a bunch of comments and some
ideas, but not much happened. Until now that is.
Hereby I release the first version of SQLStats, which is a much
enhanced version of what I described in the previous post. This
is a MySQL Plugin for MySQL 5.5 that allows you to monitor the
most recently executed, and the most frequently executed
statements using 2 INFORMATION_SCHEMA tables. The thing is not
very complex, to be honest, but it does do the job. So what was
the job then? Well, looking at what this plugin does, it goes
something like this:
- Allows you to monitor ALL SQL statements executed by the server.
- The SQL statements are "normalized", …
If you’ve ever needed to know how the data and index percentages per table engine were laid out on your MySQL server, but didn’t have the time to write out a query… here it is!
select (select (sum(DATA_LENGTH)+sum(INDEX_LENGTH))/(POW(1024,3)) as total_size from tables) as total_size_gb, (select sum(INDEX_LENGTH)/(POW(1024,3)) as index_size from tables) as total_index_gb, (select sum(DATA_LENGTH)/(POW(1024,3)) as data_size from tables) as total_data_gb, (select ((sum(INDEX_LENGTH) / ( sum(DATA_LENGTH) + sum(INDEX_LENGTH)))*100) as perc_index from tables) as perc_index, (select ((sum(DATA_LENGTH) / ( sum(DATA_LENGTH) + sum(INDEX_LENGTH)))*100) as perc_data from tables) as perc_data, (select ((sum(INDEX_LENGTH) / ( sum(DATA_LENGTH) + sum(INDEX_LENGTH)))*100) as perc_index from tables where ENGINE='innodb') as innodb_perc_index, (select ((sum(DATA_LENGTH) / ( sum(DATA_LENGTH) + sum(INDEX_LENGTH)))*100) as perc_data from tables where ENGINE='innodb') as …[Read more]
Everybody knows that parsing the output of SHOW ENGINE INNODB STATUS is hard, especially when you want to track the information historically, or want to aggregate any of the more dynamic sections such as the TRANSACTIONS one.
Within the InnoDB plugin the INFORMATION_SCHEMA.INNODB_TRX table was added, which allowed you to at least get some of the information on each transaction, but not the full breadth of information that SHOW ENGINE INNODB STATUS provided.
“This is nice..” I thought “..but why not go the whole hog..?”.. And so I set about doing that, and opened up Bug#53336. In a very short time, I was in a review process with the …
[Read more]
I wanted to get examples of some of the extra information that
the Percona server has in its INFORMATION_SCHEMA metadata, and in
doing so, I stumbled across an interesting MySQL
bug/feature/point — INFORMATION_SCHEMA tables (which are actually
system views) are case sensitive when used in comparisons:
mysql> use information_schema; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select @@version; +--------------------+ | @@version | +--------------------+ | 5.1.36-xtradb6-log | +--------------------+ 1 row in set (0.00 sec) mysql> use information_schema; Database changed mysql> show tables like 'innodb%'; Empty set (0.00 sec) mysql> show tables like 'INNODB%'; +----------------------------------------+ | Tables_in_information_schema (INNODB%) | +----------------------------------------+ | INNODB_BUFFER_POOL_PAGES_INDEX …[Read more]
To whom it may concern,
in response to a query from André Simões (also known as ITXpander),
I slapped together a MySQL script that outputs mysqldump
commands for backing up
individual partitions of the tables in the current schema.
The script is maintained as a
snippet at MySQL Forge. How it worksThe script works by
querying the information_schema.PARTITIONS
system
view to …