Update: the impact on using LIKE instead of operators in an indexed column is high. These are some test results on a table with 1,176,000 rows:
1. using datetime LIKE '2009-10-20%' => 2931ms
2. using datetime >= '2009-10-20 00:00:00' AND datetime <= '2009-10-20 23:59:59' => 168ms
Contoh Lain
Tanggal : 2018-06-02 15:50:30
1. select DATE(date_created) from data;
2018-06-02
2. select YEAR(date_created) from data;
2018
3. select MONTH(date_created) from data;
6
4. select DAY(date_created) from data;
2
5. select HOUR(date_created) from data;
15
6. select MINUTE(date_created) from data;
50
7. select SECOND(date_created) from data;
30
Tes Kecepatan dan Perbandingan penggunaan Query
QUERY 1
SELECT * FROM ttransaksi_all WHERE fid_outlet='OTL20190426095926383' AND `ftgl_transaksi` BETWEEN '2021-04-01 00:00:00' AND '2021-12-31 23:59:59'
[ Query took 2.4054 sec ]
QUERY 2
SELECT * FROM ttransaksi_all WHERE fid_outlet='OTL20190426095926383' AND `ftgl_transaksi` >= '2021-06-01 00:00:00' AND `ftgl_transaksi` <='2021-12-31 23:59:59'
[ Query took 1.2411 sec ]
0 comments:
Post a Comment