When the text and blob data type column is used in Innodb Engine. The value which are stored in that field is stored in off-page not stored in page (The default Size of Innodb page is 16kb).
My Questions are 1. What is the off-page mean? 2. How its is accessed while retrieving the value from off-page?
Database pages are the internal basic structure to organize the data in the database files. Following, some information about the InnoDB model: From 13.2.
One extent is filled with as much data as that extent can contain before another extent is used. In theory, up to 65,535 (64K) extents may used per data file; however, the recommended maximum is 32,768 (32K). The recommended maximum size for a single data file is 32G—that is, 32K extents × 1 MB per extent.
The default InnoDB page size is 16384 (16KB).
The default row format for InnoDB tables is COMPACT . The row format of a table can be defined explicitly using the ROW_FORMAT table option in a CREATE TABLE or ALTER TABLE statement. For example: CREATE TABLE t1 (c1 INT) ROW_FORMAT=COMPACT; ROW_FORMAT options include REDUNDANT , COMPACT , DYNAMIC , and COMPRESSED .
(To continue with what rlanvin and fangxing started, and to say more about about question 2.)
The ROW_FORMAT
controls some of the details about which column(s) are stored 'off-page', and also whether the entire column is off-page or whether only the part after the first 767 bytes.
If any or all is stored off-page, a 20-byte "pointer" is left behind. This contains a various fields the have the effect of identifying the 16KB page to go to to find the column value. All pages are 16KB (assuming the default; almost no one ventures into having a different page size). Hence, a big column could take multiple blocks.
The blocks come from 'extents' which are 1MB (or is it 8MB??) allocations taken from the 'tablespace' that contains the table. Originally, ibdata*
ware the only tablespaces. Later, with innodb_file_per_table
, a table could be in its own tablespace. In the near future (8.0), you will be able to define tablespaces and put whichever tables you desire into it.
When doing SHOW TABLE STATUS
(and having file_per_table), notice that the Data_free
is 4MB, 5MB, 6MB, or 7MB, reflecting the consumption of an extent.
Where are you headed with the question? One direction could be into optimizations.
SELECT
that column, then the overflow pages don't need to be accessed. (Note: This is a strong argument against blindly using SELECT *
.)ROW_FORMATs
; each is slightly better for certain types of data.LEFT(col, 10)
would not have to get the extra pages. I suspect this optimization is missing.Why is "off page" beneficial?
A partial, crude, summary of ROW_FORMATs
:
TEXT
/BLOB
/VARCHAR
/VARBLOB
) is shorter 40 bytes, it is stored on-page.COMPACT
will put 768 bytes on-page, and add a 20-byte 'pointer' to the rest (which will be off-page)DYNAMIC
or COMPRESSED
, then there is only the 20-byte pointer.KEY_BLOCK_SIZE
has some impact on on/off-page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With