I-SQL: ukusebenza kabi yize kunenkomba

Ngivele ngabhekana nenkinga yokusebenza elandelayo ye-database ye-SQL: Etafuleni le-SQL elibizwa ngokuthi "abasebenzisi" elinokufakwa okungu- ~ 1,000,000, ukuzimisela kwenani lababhalisile namuhla kuthathe imizuzwana engama-28 engamukeleki. Izikhathi zokubhaliswa zigcinwe ngefomethi ye- “Ymd H: i: s” kukholomu “eyenziwe”.


Umbuzo osetshenzisiwe

SELECT COUNT(ID) FROM users WHERE DATE(created) = '2014-12-21';

kuholele kulesi sikhathi sokulayisha, yize bekuvele kunenkomba kukholomu "edaliwe" yefomethi ye-DATETIME

ALTER TABLE `users` ADD INDEX `created` (`created`);

yayimisiwe. Isizathu sokwenza okungalungile yikholi yomsebenzi we-DATE: Ikholomu enenkomba “idaliwe” ithunyelwa ngumsebenzi DATE futhi yenza inkomba ingasebenzi. I-Query Optimizer yazi kuphela "okudaliwe", kepha hhayi umphumela we-DATE (wenziwe). Umbuzo olungiselelwe

SELECT COUNT(ID) FROM users WHERE created BETWEEN '2014-12-21' AND '2014-12-21 23:59:59';

kuholela kumphumela oyifunayo ngesikhathi semizuzwana engu-0.4.

Emuva