MySQL Forums
Forum List  »  MyISAM

Any way to force sequential reading of index blocks?
Posted by: Engel Sanchez
Date: August 19, 2009 02:21PM

Hello there. I have a large (700 million rows) table with a primary index. I/O operations that read the entire table are an order of magnitude faster when I drop the primary index. For example, if the table is:

CREATE TABLE test_table
(
value1 INT NOT NULL,
value2 INT NOT NULL,
value3 INT NOT NULL,
CONSTRAINT pk_test_table PRIMARY KEY(value1, value2, value3)
) engine = MyIsam;

Copying the entire table into another with a select into or issuing something like "select max(value3) as m from test_table" basically makes mysql read the entire table. When the primary key is dropped, reading is much faster (this is a linux 64 system, monitoring with iostat -x -m 3). It seems that when the index is not present, it reads the file sequentially and the I/O requests are merged and very efficient, whereas when the index is present, it's issuing many individual 4K random reads and efficiency drops an order of magnitude. So I imagine it's reading the index blocks not sequentially, but in index order and jumping around. Increasing the key_cache_block_size to its maximum value of 16k does make it read in larger chunks and about 3 times faster, but nowhere near as fast as the non-indexed case. (Somewhere in Google groups I read that Mysql decides the read block size based on that variable). Is there any way to force Mysql to do a sequential read of the index blocks in this case?

Thanks in advance for any pointers/help

Options: ReplyQuote


Subject
Views
Written By
Posted
Any way to force sequential reading of index blocks?
4528
August 19, 2009 02:21PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.