MariaDB [test]> CREATE TABLE `t` ( `id` int(11) NOT NULL AUTO_INCREMENT, `cid` int(11) DEFAULT NULL, `d` datetime DEFAULT NULL, `c` decimal(12,4) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB;
Query OK, 0 rows affected (0,243 sec)
MariaDB [test]> insert into t(cid, d, c) values (1, '2018-01-01', 20000.05);
Query OK, 1 row affected (0,056 sec)
MariaDB [test]> insert into t(cid, d, c) select round(rand()*100), date_sub(now(), interval rand()*100 week), round(rand()*100000,2) from t;
Query OK, 1 row affected (0,051 sec)
Records: 1 Duplicates: 0 Warnings: 0
MariaDB [test]> insert into t(cid, d, c) select round(rand()*100), date_sub(now(), interval rand()*100 week), round(rand()*100000,2) from t;
Query OK, 2 rows affected (0,040 sec)
Records: 2 Duplicates: 0 Warnings: 0
...
\MariaDB [test]> insert into t(cid, d, c) select round(rand()*100), date_sub(now(), interval rand()*100 week), round(rand()*100000,2) from t;
Query OK, 32768 rows affected (0,794 sec)
Records: 32768 Duplicates: 0 Warnings: 0
MariaDB [test]> insert into t(cid, d, c) select round(rand()*100), date_sub(now(), interval rand()*100 week), round(rand()*100000,2) from t;
Query OK, 65536 rows affected (1,400 sec)
Records: 65536 Duplicates: 0 Warnings: 0
MariaDB [test]> select count
from t;
----------
count |
----------
----------
1 row in set (0,070 sec)
MariaDB [test]> select distinct cid, week(d) as week, max(c) over (partition by cid, week(d)) as c_mx, sum(c) over (partition by cid, week(d)) as c_sum, count(c) over (partition by cid, week(d)) as c_cnt, max(week(d)) over (partition by year(d)) as w_max from t where year(d) = '2018';
ERROR 2013 (HY000): Lost connection to MySQL server during query
MariaDB [test]> CREATE TABLE `t` ( `id` int(11) NOT NULL AUTO_INCREMENT, `cid` int(11) DEFAULT NULL, `d` datetime DEFAULT NULL, `c` decimal(12,4) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB;
Query OK, 0 rows affected (0,243 sec)
MariaDB [test]> insert into t(cid, d, c) values (1, '2018-01-01', 20000.05);
Query OK, 1 row affected (0,056 sec)
MariaDB [test]> insert into t(cid, d, c) select round(rand()*100), date_sub(now(), interval rand()*100 week), round(rand()*100000,2) from t;
Query OK, 1 row affected (0,051 sec)
Records: 1 Duplicates: 0 Warnings: 0
MariaDB [test]> insert into t(cid, d, c) select round(rand()*100), date_sub(now(), interval rand()*100 week), round(rand()*100000,2) from t;
Query OK, 2 rows affected (0,040 sec)
Records: 2 Duplicates: 0 Warnings: 0
...
\MariaDB [test]> insert into t(cid, d, c) select round(rand()*100), date_sub(now(), interval rand()*100 week), round(rand()*100000,2) from t;
Query OK, 32768 rows affected (0,794 sec)
Records: 32768 Duplicates: 0 Warnings: 0
MariaDB [test]> insert into t(cid, d, c) select round(rand()*100), date_sub(now(), interval rand()*100 week), round(rand()*100000,2) from t;
Query OK, 65536 rows affected (1,400 sec)
Records: 65536 Duplicates: 0 Warnings: 0
MariaDB [test]> select count
from t;
----------
----------
----------
1 row in set (0,070 sec)
MariaDB [test]> select distinct cid, week(d) as week, max(c) over (partition by cid, week(d)) as c_mx, sum(c) over (partition by cid, week(d)) as c_sum, count(c) over (partition by cid, week(d)) as c_cnt, max(week(d)) over (partition by year(d)) as w_max from t where year(d) = '2018';
ERROR 2013 (HY000): Lost connection to MySQL server during query