P
P
PowerUSB2017-10-17 14:21:14
MySQL
PowerUSB, 2017-10-17 14:21:14

How to put indexes in MySQL?

Hello. There is a table of type InnoDB, it has about 10 million records.
It has the following structure:


ID int(11)
MarketName varchar(255)
High double
Low double
Volume double
Last double
BaseVolume double
TimeStamp timestamp
Bid double
Ask double
OpenBuyOrders int(11)
OpenSellOrders int(11)

The database is selected by the following request:
SELECT * FROM `crm_exchanges_bittrex_currencies` WHERE `TimeStamp` BETWEEN STR_TO_DATE('2017-10-19 00:00:00', '%Y-%m-%d %H:%i:%s') AND STR_TO_DATE('2017-10-20 23:59:59', '%Y-%m-%d %H:%i:%s') and `MarketName` = 'BITCNY-BTC'

Help to expose correctly indexes at the table that the request of selection would be processed faster.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2017-10-17
@PowerUSB

create index crm_exchanges_bittrex_currencies_market_time_idx on crm_exchanges_bittrex_currencies (MarketName, TimeStamp);

R
Ruslan Fedoseev, 2017-10-17
@martin74ua

discover the explain command

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question