I am currently working on a financial application. A MYSql Database with 8 columns. 1 Million records.
INSERTS : 30 rows per minute.
UPDATES : 0.
SELECTS : A query that runs once every 200ms. Returns around 200,000 records for each execution.
Select Query as follows:
SELECT COLUMNB, COLUMNC, COLUMND, COLUMNE FROM TABLE
WHERE COLUMNE IN('ABCD','EFGH','IJKL','MNOP')
ORDER BY COLUMNB DESC
my response times are as follows: Execution :0.903 Seconds Fetch : 0.2 Seconds.
Total ~ 1.1 seconds
When i do an Explain I get the following:
id, select_type, table, partitions, type, possible_keys, key, key_len, ref, rows, filtered, Extra '1', 'SIMPLE', 'table', NULL, 'ALL', 'tbl_ColumnE_ColumnB,tbl_ColumnE', NULL, NULL, NULL, '1180834', '34.33', 'Using where; Using filesort'
INDEXES already active:
- tbl_ColumnE_ColumnB,
- tbl_ColumnB_ColumnE,
- tbl_ColumnE
- tbl_ColumnB
As this is a financial Stock market based application. I need to get total execution time further down to close to 200milliseconds or lesser as possible. Is there anything i can improve?
Already done :
- innodb_buffer_pool increase from 8M to 2000M (saved 30%)
- Changed OR operator to IN operator ( it was OR before. Saved 20%)
Show Create Table :
CREATE TABLE `tbl` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`COLUMNB` timestamp NULL DEFAULT NULL,
`COLUMNC` decimal(20,10) DEFAULT NULL,
`COLUMND` decimal(20,10) DEFAULT NULL,
`COLUMNX` decimal(20,10) DEFAULT NULL,
`COLUMNY` decimal(20,10) DEFAULT NULL,
`COLUMNZ` decimal(20,10) DEFAULT NULL,
`COLUMNE` varchar(45) DEFAULT NULL,
`COLUMNF` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`),
KEY `tbl_ColumnE_ColumnB` (`ColumnE`,`ColumnB`),
KEY `tbl_ColumnB_ColumnE` (`ColumnB`,`ColumnE`),
KEY `tbl_ColumnB` (`ColumnB`),
KEY `tbl_ColumnE` (`ColumnE`)
) ENGINE=InnoDB AUTO_INCREMENT=1718507 DEFAULT CHARSET=utf8'