RigacciOrg / AirPi

A monitoring station for air quality based on Raspberry Pi
GNU General Public License v3.0
23 stars 15 forks source link

Cannot access Calendar history #1

Closed RigacciOrg closed 6 years ago

RigacciOrg commented 6 years ago

The AirPi station is running for a long time (about one year), so the SQLite database /var/lib/airpi/airpi-data.db is grown to about 300 Mb in size. When I click on the Calendar page, the page remains blank, where the Nginx error log says something about:

PHP Fatal error: Maximum execution time of 30 seconds exceeded

may be the data extraction from database is not optimized.

RigacciOrg commented 6 years ago

The query over the SQLite datbase was not well optimized, so it required more than 30 seconds (default PHP timeout).

The problem should be fixed by commits 523a51edb906d3b5a002bef5e92be6c974414e76, 66e8205bb78bdadf3f63adb866e9779483d7c2f8 and 2f76cacbdce89542000c02201d4fef83c0e79d62 (updated files lib/airpi-data-export, lib/airpi-sql-insert and html/getpmdata.php). Unfortunately a new index must be created into the database, this will increase the size (e.g. from 376 Mb a 478 Mb in my test case). To add the index, run this command (it requires some minutes to complete):

sqlite3  /var/lib/airpi/airpi-data.db
CREATE INDEX data_type_timestamp_idx ON data (type, timestamp);