Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL: What is a page?

I can't for the life of me remember what a page is, in the context of a MySQL database. When I see something like 8KB/page, does that mean 8KB per row or ...?

like image 454
Matty Avatar asked Dec 09 '10 18:12

Matty


People also ask

What is a page in a database?

A page is a unit of storage whose size is configurable on a system-wide, database-wide, or conglomerate-specific basis. By default, a conglomerate grows one page at a time until eight pages of user data (or nine pages of total disk use, which includes one page of internal information) have been allocated.

What is page size in MySQL?

By default, all tablespaces have a page size of 16KB; you can reduce the page size to 8KB or 4KB by specifying the innodb_page_size option when you create the MySQL instance. The pages are grouped into extents of size 1MB (64 consecutive 16KB pages, or 128 8KB pages, or 256 4KB pages).

What is InnoDB page size?

The default InnoDB page size is 16384 (16KB).


2 Answers

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.11.2. File Space Management:

The data files that you define in the configuration file form the InnoDB tablespace. The files are logically concatenated to form the tablespace. [...] The tablespace consists of database pages with a default size of 16KB. The pages are grouped into extents of size 1MB (64 consecutive pages). The “files” inside a tablespace are called segments in InnoDB.

And from 13.2.14. Restrictions on InnoDB Tables

The default database page size in InnoDB is 16KB. By recompiling the code, you can set it to values ranging from 8KB to 64KB.

Further, to put rows in relation to pages:

The maximum row length, except for variable-length columns (VARBINARY, VARCHAR, BLOB and TEXT), is slightly less than half of a database page. That is, the maximum row length is about 8000 bytes. LONGBLOB and LONGTEXT columns must be less than 4GB, and the total row length, including BLOB and TEXT columns, must be less than 4GB.

like image 158
MicSim Avatar answered Sep 24 '22 03:09

MicSim


Well,

its not really a question about MySql its more about what page size is in general in memory management.

You can read about that here: http://en.wikipedia.org/wiki/Page_(computer_memory)

Simply put its the smallest unit of data that is exchanged/stored.

The default page size is 4k which is probably fine.

If you have large data-sets or only very few write operations it may improve performance to raise the page size.

Have a look here: http://db.apache.org/derby/manuals/tuning/perf24.html

Why? Because more data can be fetched/addressed at once. If the probability is high that the desired data is in close proximity to the data you just fetched, or directly afterwards (well its not really in 3d space but i think you get what i mean), you can just fetch it along in one operation and take better advantage of several caching and data fetching technologies, in general from your hard drive.

But on the other side you waste space if you have data that doesn't fill up the page size or is just a little bit more or something.

I personally never had a case where tuning the page size was important. There were always better approaches to optimize performance, and if not, it was already more than fast enough.

like image 31
The Surrican Avatar answered Sep 24 '22 03:09

The Surrican