I am trying to process millions of records from my table (size is about 30 GB) and I am currently doing it using paging (mysql 5.1.36). The query I use in my for loop is
select blobCol from large_table
where name= 'someKey' and city= 'otherKey'
order by name
LIMIT <pageNumber*pageSize>, <pageSize>
This works perfectly fine for about 500K records. I have a page size of 5000 that I am using and after page 100, the queries start slowing down dramatically. The first ~80 pages are extracted in a 2-3 seconds but after around page 130, each page takes about 30 seconds to retrieve, at least until page 200. One of my queries has about 900 pages and that would take too long.
The table structure is (type is MyISAM)
name char(11)
id int // col1 & col2 is a composite key
city varchar(80) // indexed
blobCol longblob
what can i do to speed it up? The explain for the query shows this
select_type: SIMPLE
possible_keys: city
key : city
type: ref
key_len: 242
ref: const
rows: 4293720
Extra: using where; using filesort
In case it helps, the my.cnf for my server (24 GB ram, 2 quad core procs) has these entries
key_buffer_size = 6144M
max_connections = 20
max_allowed_packet = 32M
table_open_cache = 1024
sort_buffer_size = 256M
read_buffer_size = 128M
read_rnd_buffer_size = 512M
myisam_sort_buffer_size = 128M
thread_cache_size = 16
tmp_table_size = 128M
max_heap_table_size = 64M