Kaliya waxaa i soo food saartay dhibaatada waxqabadka ee soo socota ee xogta SQL: Miiska SQL ee loo yaqaan "isticmaalayaasha" oo ay la socdaan ~ 1,000,000 soo gelitaan, go'aaminta tirada diiwaangelinta maanta waxay qaadatay 28 sekan oo aan la aqbali karin. Waqtiyada diiwaangelinta ayaa lagu keydiyay qaabkii "Ymd H: i: s" ee safka "la abuuray".
Weydiinta la adeegsaday
SELECT COUNT(ID) FROM users WHERE DATE(created) = '2014-12-21';
horseeday waqtigan rarka, in kasta oo ay horey u jireen tixraac ku yaal safka "la abuuray" ee qaabka DATETIME
ALTER TABLE `users` ADD INDEX `created` (`created`);
ayaa la dhigay. Sababta waxqabadka liidata waa wacitaanka DATE function: Tiirka tixda la saaray "la abuuray" waxaa soo diray hawl DATE wuxuuna ka dhigayaa tusmada mid aan waxtar lahayn. Su'aalaha Optimizer kaliya ayaa garanaya "la abuuray", laakiin maahan natiijada DATE (la abuuray). Weydiinta ugufiican
SELECT COUNT(ID) FROM users WHERE created BETWEEN '2014-12-21' AND '2014-12-21 23:59:59';
waxay u horseedaa natiijada la rabay muddo ah 0.4 ilbidhiqsi.