Skip to content

Instantly share code, notes, and snippets.

@RoyBellingan
Last active August 29, 2015 13:56
Show Gist options
  • Save RoyBellingan/9300236 to your computer and use it in GitHub Desktop.
Save RoyBellingan/9300236 to your computer and use it in GitHub Desktop.
Important bit of my.cnf
innodb_buffer_pool_size = 5000M
Server is an AMD OPTERON 6128 (2.0 GHz) 8Gb Ram (MySQL is using 70% of them), test was done on nightly our so load is nearly absent.
The from clause is extracted from the query archiving phase
The log_link_visit_action table is ~6,871,070 row and 0.9Gb of data, spanning 3 weeks
(query was executed multiple times (10x), times is the median, first run has been discarded)
**********************
select SQL_NO_CACHE count(*)
from log_link_visit_action
WHERE log_link_visit_action.server_time >= '2014-02-21 22:59:59' AND log_link_visit_action.server_time <= '2014-03-28 22:59:59' AND log_link_visit_action.idsite = '15'
+----------+
| count(*) |
+----------+
| 2170575 |
+----------+
# Rows_examined: 2170575
time 1,875 sec
**********************
select SQL_NO_CACHE count(*)
from log_link_visit_action
WHERE BETWEEN date( '2014-02-21 22:59:59' ) AND date('2014-03-28 22:59:59') AND log_link_visit_action.idsite = '15'
+----------+
| count(*) |
+----------+
| 2170575 |
+----------+
#Rows_examined: 2568466
Query_time: 1.68
I Don't know why it scans more row... but is a bit faster... not a game changer of course but something...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment