Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huge amount of queries #467

Closed
reboot1983 opened this issue Mar 22, 2017 · 5 comments
Closed

Huge amount of queries #467

reboot1983 opened this issue Mar 22, 2017 · 5 comments

Comments

@reboot1983
Copy link
Contributor

reboot1983 commented Mar 22, 2017

Running cacti 1.1.0 on my Raspberry Pi 3b:

When activating the MySQL general_log setting in the my.cnf and requesting the following url:
http://192.168.1.3/cacti/graph_view.php?action=get_node&tree_id=0&id=%23

This is an ajax request for requesting the main tree node in de graphs tab of cacti.

I get a huge amount of queries listed in the log. A lot of the queries are the same and are requesting the same variables in de settings table. Also there are queries querying primary keys with value 0 (zero).

I've attached the mysql.txt (see section 85 for all the queries executed for requesting this URL).
mysql.txt

Maybe it's possible to cache requested settings in a class (or collect all settings from the table in a static class and ask the class for the value of the specific setting). This should generate a lot less traffic with the MySQL server.

@reboot1983 reboot1983 changed the title settings table caching mechanism seems not functional Huge amount of queries Mar 22, 2017
@cigamit
Copy link
Member

cigamit commented Mar 22, 2017

This is mainly calls to the settings table, which is odd. We already are supposed to cache those entries. I'll take a look and see what's up.

@cigamit
Copy link
Member

cigamit commented Mar 22, 2017

Just out of curiosity, are you doing those calls as the guest account, or some other account?

cigamit added a commit that referenced this issue Mar 22, 2017
Reduce the number of queries in the log function
@cigamit
Copy link
Member

cigamit commented Mar 22, 2017

Pull the latest lib/functions.php and let us know how it was reduced.

@reboot1983
Copy link
Contributor Author

reboot1983 commented Mar 23, 2017

I was calling as user_id = 1 (admin)

I've pulled the latest functions.php, but overwriting my 1.1.0 versions with the pulled one resulted in HTTP500. So I checked your changes and patched them manually in my 1.1.0 version of functions.php. It feels as if cacti loads much faster and the mysql.log also has less queries. For exact the same scenario, the file is almost 50% reduced.

mysql_github_patched1.txt

@cigamit
Copy link
Member

cigamit commented Mar 24, 2017

Okay, closing this. Moving on. Looking forward to that pull request. The lib/auth.php is a beast. Please be careful.

@cigamit cigamit closed this as completed Mar 24, 2017
@github-actions github-actions bot locked and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants