MySQL:什么是页面?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4401910/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL: What is a page?
提问by Matty
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 ...?
在 MySQL 数据库的上下文中,我终生无法记住页面是什么。当我看到像 8KB/page 这样的东西时,这是否意味着每行 8KB 或...?
采纳答案by MicSim
Database pages are the internal basic structure to organize the data in the database files. Following, some information about the InnoDB model:
数据库页面是组织数据库文件中数据的内部基本结构。以下是有关 InnoDB 模型的一些信息:
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.
您在配置文件中定义的数据文件构成 InnoDB 表空间。这些文件在逻辑上连接起来形成表空间。[...] 表空间由默认大小为 16KB 的数据库页组成。这些页面被分组到大小为 1MB(64 个连续页面)的区中。表空间中的“文件”在 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.
InnoDB 中的默认数据库页面大小为 16KB。通过重新编译代码,您可以将其设置为 8KB 到 64KB 范围内的值。
Further, to put rowsin 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.
除了可变长度列(VARBINARY、VARCHAR、BLOB 和 TEXT)之外,最大行长度略小于数据库页面的一半。也就是说,最大行长度约为 8000 字节。LONGBLOB 和 LONGTEXT 列必须小于 4GB,总行长(包括 BLOB 和 TEXT 列)必须小于 4GB。
回答by The Surrican
Well,
好,
its not really a question about MySql its more about what page size is in general in memory management.
这并不是一个关于 MySql 的问题,它更多地是关于内存管理中通常的页面大小。
You can read about that here: http://en.wikipedia.org/wiki/Page_(computer_memory)
你可以在这里阅读: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.
默认页面大小为 4k,这可能没问题。
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
看看这里: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.
为什么?因为可以一次获取/寻址更多数据。如果所需数据与您刚刚获取的数据或直接获取的数据非常接近的可能性很高(它不是真的在 3d 空间中,但我认为您明白我的意思),您可以通过一次操作获取它并更好地利用几种缓存和数据获取技术,通常是从您的硬盘驱动器。
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.
我个人从未遇到过调整页面大小很重要的情况。总是有更好的方法来优化性能,如果没有,它已经足够快了。
回答by Riedsio
It's the size of which data is stored/read/written to disk and in memory.
它是将数据存储/读取/写入磁盘和内存的大小。
Different page sizes might work better or worse for different work loads/data sets; i.e. sometimes you might want more rows per page, or less rows per page. Having said that, the default page size is fine for the majority of applications.
对于不同的工作负载/数据集,不同的页面大小可能会更好或更糟;即有时您可能希望每页多行,或每页少行。话虽如此,默认页面大小适用于大多数应用程序。
Note that "pages" aren't unique for MySQL. It's an aspect of a parameter for all databases.
请注意,“页面”对于 MySQL 不是唯一的。它是所有数据库参数的一个方面。

