Доброе утро.
Решил сделать тестовую БД с 500k строками.
Структура:
[id | post_id | text | time]
post_id - число в цикле for ($i = 0; $i < 1000000; $i++)
time - функция time(); в PHP
Делаю запрос:
SELECT * FROM `test`;
- результат:
....................*тут предыдущие строчки*....................
| 579777 | 579776 | text | 1524706021 |
| 579778 | 579777 | text | 1524706021 |
| 579779 | 579778 | text | 1524706021 |
| 579780 | 579779 | text | 1524706021 |
| 579781 | 579780 | text | 1524706021 |
| 579782 | 579781 | text | 1524706021 |
| 579783 | 579782 | text | 1524706021 |
| 579784 | 579783 | text | 1524706021 |
| 579785 | 579784 | text | 1524706021 |
| 579786 | 579785 | text | 1524706021 |
| 579787 | 579786 | text | 1524706021 |
| 579788 | 579787 | text | 1524706021 |
| 579789 | 579788 | text | 1524706021 |
| 579790 | 579789 | text | 1524706021 |
| 579791 | 579790 | text | 1524706021 |
| 579792 | 579791 | text | 1524706021 |
| 579793 | 579792 | text | 1524706021 |
| 579794 | 579793 | text | 1524706021 |
| 579795 | 579794 | text | 1524706021 |
| 579796 | 579795 | text | 1524706021 |
| 579797 | 579796 | text | 1524706021 |
| 579798 | 579797 | text | 1524706021 |
| 579799 | 579798 | text | 1524706021 |
| 579800 | 579799 | text | 1524706021 |
| 579801 | 579800 | text | 1524706021 |
| 579802 | 579801 | text | 1524706021 |
| 579803 | 579802 | text | 1524706021 |
| 579804 | 579803 | text | 1524706021 |
| 579805 | 579804 | text | 1524706021 |
| 579806 | 579805 | text | 1524706021 |
| 579807 | 579806 | text | 1524706021 |
| 579808 | 579807 | text | 1524706021 |
| 579809 | 579808 | text | 1524706021 |
| 579810 | 579809 | text | 1524706021 |
| 579811 | 579810 | text | 1524706021 |
+--------+---------+------+------------+
579811 rows in set (38.90 sec)
Делаю запрос:
SELECT * FROM `test` WHERE `post_id`>1 AND `post_id`<100
- результат:
| 84 | 83 | text | 1524705788 |
| 85 | 84 | text | 1524705788 |
| 86 | 85 | text | 1524705788 |
| 87 | 86 | text | 1524705788 |
| 88 | 87 | text | 1524705788 |
| 89 | 88 | text | 1524705788 |
| 90 | 89 | text | 1524705788 |
| 91 | 90 | text | 1524705788 |
| 92 | 91 | text | 1524705788 |
| 93 | 92 | text | 1524705788 |
| 94 | 93 | text | 1524705788 |
| 95 | 94 | text | 1524705788 |
| 96 | 95 | text | 1524705788 |
| 97 | 96 | text | 1524705788 |
| 98 | 97 | text | 1524705788 |
| 99 | 98 | text | 1524705788 |
| 100 | 99 | text | 1524705788 |
+-----+---------+------+------------+
98 rows in set (27.52 sec)
Мне кажется, что это оооочень много для вывода 100 строк, как можно оптимизировать сам MySQL? (стоит MYISAM)
Параметры:
1CPUx2400MHz
512MB RAM
10GB SSD