Skip to content
darnaut edited this page Oct 3, 2014 · 3 revisions

Table of contents

Quick start

Installing using RubyGems

To install as root:

sudo gem install innodb_ruby

To install as a user:

gem install --user-install innodb_ruby

To run:

innodb_space ...

Installing from Source Repository

Clone repository:

git clone https://github.com/jeremycole/innodb_ruby.git
cd innodb_ruby

To run:

ruby -r rubygems -I lib bin/innodb_space ...

Basic tutorial

Basics of using innodb_space from the command line. There are two ways to start innodb_space.

Against a single space file (ibdata or .ibd):

Option Parameters Description
-f <filename> Load the tablespace file (system or table)

Against a system tablespace which will auto-load file-per-table tablespace files:

Option Parameters Description
-s <filename> Load the system tablespace file (e.g. ibdata1)
-T <table name> Use the given table name.
-I <index name> Use the given index name

Space File Structure

system-spaces

List all tablespaces available from the system, including some basic stats. This is basically a list of tables:

innodb_space -s ibdata1 system-spaces

space-indexes

List all indexes available from the space (system space or file-per-table space):

innodb_space -s ibdata1 -T sakila/film space-indexes

space-page-type-regions

Iterate through all pages in a space and print a summary of page types coalesced into “regions” of same-type pages:

innodb_space -s ibdata1 -T sakila/film space-page-type-regions

space-page-type-summary

Iterate through all pages and print a summary of total counts of pages by type:

innodb_space -s ibdata1 -T sakila/film space-page-type-summary

space-extents-illustrate

Illustrate all pages in all extents in the space, showing a colorized block (colored by index/purpose) for each page, sized based on the amount of data in the page:

innodb_space -s ibdata1 -T sakila/film space-extents-illustrate

space-lsn-age-illustrate

Illustrate all pages in all extents in the space, showing a colorized block (colored by the age of the modification LSN for the page):

innodb_space -s ibdata1 -T sakila/payment space-lsn-age-illustrate

Page Structure

page-account

Given any page number, explain what the page is used for (for most structures):

innodb_space -s ibdata1 -T sakila/film -p 3 page-account

page-dump

Intelligently dump the contents of a page including a representation of most structures that innodb_ruby understands:

innodb_space -s ibdata1 -T sakila/film -p 3 page-dump

page-records

Summarize all records within the page:

innodb_space -s ibdata1 -T sakila/film -p 3 page-records

page-directory-summary

Dump the contents of the page directory for a page

innodb_space -s ibdata1 -T sakila/film -p 7 page-directory-summary

page-illustrate

Illustrate the content of a page:

innodb_space -s ibdata1 -T sakila/film -p 7 page-illustrate

Index Structure

index-recurse

Recurse an index (perform a full index scan) by following the entire B+Tree (scanning all pages by recursion, not just the leaf pages by list):

innodb_space -s ibdata1 -T sakila/film -I PRIMARY index-recurse

index-record-offsets

Recurse an index as index-recurse does, but print the offset of each record within the index pages:

innodb_space -s ibdata1 -T sakila/film -I PRIMARY index-record-offsets

index-level-summary

Print a summary of all index pages at a given level:

innodb_space -s ibdata1 -T sakila/film -I PRIMARY -l 0 index-level-summary

Record Structure

record-dump

Given a record offset, dump a detailed description of a record and the data it contains:

innodb_space -s ibdata1 -T sakila/film -p 7 -R 128 record-dump

Record History

record-history

Summarize the history (undo logs) of a record:

innodb_space -s ibdata1 -T sakila/film -p 7 -R 128 record-history

Additional exploration

space-lists

Show a summary of the lists (free, free_frag, full_frag, free_inodes, and full_inodes) for the space, including the list length and the list node information of the first and last pages in the list:

innodb_space -s ibdata1 space-lists

space-list-iterate

Iterate through all extents in a list and show the extents or inodes in the list:

innodb_space -s ibdata1 space-list-iterate -L free_frag

space-inodes-summary

Print summary information for each inode in the space:

innodb_space -s ibdata1 space-inodes-summary

undo-history-summary

Print a summary of all records in the history list (undo logs):

innodb_space -s ibdata1 undo-history-summary

undo-record-dump

Print a detailed description of an undo record and the data it contains:

innodb_space -s ibdata1 -p page -R offset undo-record-dump

Using the innodb_ruby library

$ irb -r innodb
> sys = Innodb::System.new("ibdata1")
> idx = sys.index_by_name("sakila/film", "PRIMARY")
> rec = idx.binary_search([1])