I am running a very simple query on an indexed column in a 20 mln row table.
select * from prvol where date = '20100203';
It takes about 22 seconds. I am new to sql, but think that an indexed column should be faster than this. There is no memory issue. Also, the output says the time is mostly in network. I’m running the query on the same machine the server is on.
/* 0 rows affected, 6,882 rows found. Duration for 1 query: 0.828 sec. (+ 21.438 sec. network) */
What does that network time mean? Would you expect this query to run faster?
EDIT: as requested, here is some output.
EXPLAIN SELECT * FROM prvol WHERE date = '20100203';
"id","select_type","table","type","possible_keys","key","key_len","ref","rows","Extra"
"1","SIMPLE","prvol","ref","Index 1","Index 1","4","const","6881","Using where"
SHOW CREATE TABLE prvol;
"Table","Create Table"
"prvol","CREATE TABLE `prvol` (
`exch` varchar(10) DEFAULT NULL,
`ticker` varchar(10) DEFAULT NULL,
`date` date DEFAULT NULL,
`open` float unsigned DEFAULT NULL,
`high` float unsigned DEFAULT NULL,
`low` float unsigned DEFAULT NULL,
`close` float unsigned DEFAULT NULL,
`vs` float unsigned DEFAULT NULL,
`aclose` float DEFAULT NULL,
KEY `Index 1` (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1"
I eventually figured out why my query was slow. See here for answer. It ended up having nothing to do with network time. It was a cache size issue.