Mysql query is very slow in datestamp in timestamp

There is one table in the mysql table that has about 1.76 million records and is growing. It seems the more records, the slower it gets. It takes about 65 seconds to complete the simple query below. Date_run is a timestamp field. I wonder if this makes it work slower. Any suggestions that I can customize in the options file to make this babe faster?

select *
from stocktrack
where date(date_run) >= '2014-5-22'
and date(date_run) <= '2014-5-29'
  • mysql version 5.6
  • Windows 8.1 64 bit
  • Intel Core i7-4770, 3.40 GHz 12 GB RAM
+4
source share
2 answers

, ( date_run ) " " .

(, DATE(), ) MySQL . , , MySQL .

"", :

WHERE date_run >= '2014-5-22' AND date_run <  '2014-5-29' + INTERVAL 1 DAY

( , , , MySQL "00: 00: 00". , "2014-05 -29 ' ' 2014-05-30 '.)

MySQL , . , , :

... ON stocktrack (date_run) 

( , date_run .)

() ( ) , MySQL . MySQL .

EXPLAIN MySQL .


, ...

"... ..."

, (MyISAM InnoDB). , -... , , , . MySQL, , , dba.stackexchange.com.

+9

date_run, ( , "Y-m-d H: i: s" )

select 
    *
from 
    stocktrack
where 
    date_run >= '2014-05-22 00:00:00'
    and date_run <= '2014-05-29 00:00:00'
+1

Source: https://habr.com/ru/post/1542602/


All Articles