I run a very simple MySQL database construct. I only have like id, TimeStamp and OP_fs155e columns which I consider is extremely basic setup.
MariaDB [gadbdfm]> desc optical_power;
+-----------+------------------+------+-----+----------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------------+------+-----+----------------------+-----------------------------+
| id_record | int(10) unsigned | NO | PRI | NULL | auto_increment |
| TimeStamp | timestamp(6) | NO | | CURRENT_TIMESTAMP(6) | on update CURRENT_TIMESTAMP |
| OP_fs155e | varchar(30) | YES | MUL | NULL | |
| data1 | varchar(30) | YES | | NULL | |
| data2 | varchar(30) | YES | | NULL | |
| data3 | varchar(30) | YES | | NULL | |
| data4 | varchar(30) | YES | | NULL | |
| data5 | varchar(30) | YES | | NULL | |
+-----------+------------------+------+-----+----------------------+-----------------------------+
8 rows in set (0.00 sec)
However, I start noticing that my selects are terribly slow first at Raspberry Pi 3 (as master) and Centos7 (as slave - 8GB muscle server). Here is my select everything at slave server which took several minutes. I thought that the problem is that Raspberry Pi 3 is too slow but when I found out that it is the same at a real server slave, there is definitively something wrong with it.
MariaDB [gadbdfm]> select TimeStamp,OP_fs155e from optical_power;
| 2017-01-01 17:41:03.697000 | -24 |
| 2017-01-01 17:42:03.666000 | -24 |
| 2017-01-01 17:43:03.701000 | -24 |
| 2017-01-01 17:44:03.675000 | -24 |
| 2017-01-01 17:45:03.676000 | -24 |
| 2017-01-01 17:46:03.692000 | -24 |
| 2017-01-01 17:47:03.686000 | -24 |
| 2017-01-01 17:48:03.539000 | -24 |
| 2017-01-01 17:49:03.581000 | -24 |
+----------------------------+-----------+
23044062 rows in set (37.24 sec)
Master my.cnf
pi@rpi3jantoth - /opt/FlightStrata155E cat /etc/mysql/mysql.conf.d/mysqld.cnf | grep -v "#" | grep -v "^$"
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
bind-address = 0.0.0.0
key_buffer_size = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
myisam-recover = BACKUP
query_cache_limit = 1M
query_cache_size = 16M
log_error = /var/log/mysql/error.log
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/mysql-relay-bin.index
log-error = /var/lib/mysql/mysql.err
Slave my.cnf:
[root@fiber ~]# cat /etc/my.cnf | grep -v "#" | grep -v "^$"
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
server-id = 2
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
!includedir /etc/my.cnf.d
I know that I have zero optimization in my scheme.
One more example:
This select on Raspberry Pi 3 takes like 7 minutes
mysql> select TimeStamp, OP_fs155e from optical_power ORDER BY TimeStamp desc limit 15;
Hello @Bill Karwin and @Bernd Buffen! I highly appreciate your advice! I added like this index as show and explained in the presentation here:
and the result is 3.24 seconds compared to 2 minutes ot 7 minutes sometimes: AMAZING!!!