简体   繁体   中英

MySQL - Reading from disk table with Primary Key

I am experimenting with MYSQL and I am wondering what happens if on a big table (> 10 Mio rows) I reduce the memory table to a minimum (lets say 100MB) and let MYSQL fetch everything straight from the disk table. Since I am accessing the rows through Primary Keys I really wonder if:

Does MySQL need to scan the whole table or can it take advantage of the Tree at the disk level too?

Any hints would be highly appreciated,

Thanks.

Of course MySQL will take advantage of whatever index structures are in place to optimize disk access. Whether they apply to a given query is a different matter; but if the SQL engine can, then it will.

You may be thinking about the memory model of databases the wrong way. Data is stored on pages. These pages normally reside on disk. There is an intermediate cache that optimizes disk access. So, the page reference is to a page address on disk.

When the SQL engine wants to go to a particular page, it first looks through the cache to see if it is already available (as well as checking other factors such as whether it has been modified -- a dirty page). If available in the page cache, then the engine uses that version. If not available, then it loads the disk image of the page into the cache (and perhaps some nearby pages). If no room is in the cache, then one or more pages are "flushed" to make space for the new page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM