CLI Scripts unusable
Moderators: Developers, Moderators
- TheWitness
- Developer
- Posts: 17059
- Joined: Tue May 14, 2002 5:08 pm
- Location: MI, USA
- Contact:
For your size implementation that looks good, unless you have several other large databases on that system.
TheWitness
TheWitness
True understanding begins only when we realize how little we truly understand...
Life is an adventure, let yours begin with Cacti!
Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages
For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Life is an adventure, let yours begin with Cacti!
Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages
For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
-
- Posts: 2
- Joined: Fri Jan 19, 2007 11:34 am
-
- Posts: 2
- Joined: Fri Jan 19, 2007 11:34 am
Initially after adding the index I was still seeing very slow times too.
What I found helped was doing an "OPTIMIZE TABLE `data_input_data`". Obviously it must have gotton quite fragmented or something as running this seems to have worked a treat. Afer that I was back into sub 5 second run of add_graphs vs the minutes it eventually got up to (this is on a test box, not on production hardware yet!).
Probably an idea to run it out of cron daily with a simple shell script such as:
What I found helped was doing an "OPTIMIZE TABLE `data_input_data`". Obviously it must have gotton quite fragmented or something as running this seems to have worked a treat. Afer that I was back into sub 5 second run of add_graphs vs the minutes it eventually got up to (this is on a test box, not on production hardware yet!).
Probably an idea to run it out of cron daily with a simple shell script such as:
Code: Select all
#!/bin/bash
TABLES=`echo "show tables;" | /usr/bin/mysql cacti --user=USER --password=PASSWORD | tail +2`
for each in `echo $TABLES`; do
echo "OPTIMIZE TABLE \`$each\`" | /usr/bin/mysql cacti --user=USER --password=PASSWORD
done
after optimize tables and setting the index still > 10s
Hello,
after optimizing the mysql tables and setting the index "ALTER TABLE `data_input_data` ADD INDEX ( `t_value` );" my script still needs approx. 10 - 13 seconds to insert one graph. Very much better than the runtime before, but not enough...
Because I have to add 10.000 Graphs it will take around 27 hours to complete, which is too much time...
through the web-interface one can create approx. 500 graphs within a minute or two!
Has anybody any more / new suggestions on how to optimize the overall runtime of the add_graphs.php script?
Any help is highly welcome!
thanks in advance,
Tom
after optimizing the mysql tables and setting the index "ALTER TABLE `data_input_data` ADD INDEX ( `t_value` );" my script still needs approx. 10 - 13 seconds to insert one graph. Very much better than the runtime before, but not enough...
Because I have to add 10.000 Graphs it will take around 27 hours to complete, which is too much time...
through the web-interface one can create approx. 500 graphs within a minute or two!
Has anybody any more / new suggestions on how to optimize the overall runtime of the add_graphs.php script?
Any help is highly welcome!
thanks in advance,
Tom
slow query takes 10-14 seconds to complete
Hello,
as Alice already pointed out the following query takes approx. 10-14 seconds to return results (found in the slow-query-log):
SELECT DISTINCT data_input_fields.data_name AS `name`, data_input_fields.name AS `description`, data_input_data.value AS `default`, data_template_data.data_template_id, data_input_fields.id AS `data_input_field_id` FROM data_input_data INNER JOIN (((data_template_rrd INNER JOIN (graph_templates INNER JOIN graph_templates_item ON graph_templates.id = graph_templates_item.graph_template_id) ON data_template_rrd.id = graph_templates_item.task_item_id) INNER JOIN data_template_data ON data_template_rrd.data_template_id=data_template_data.data_template_id) INNER JOIN data_input_fields ON data_template_data.data_input_id=data_input_fields.data_input_id) ON (data_input_data.data_template_data_id = data_template_data.id) AND (data_input_data.data_input_field_id = data_input_fields.id) WHERE (((graph_templates.id)=2) AND ((data_input_data.t_value)='on') AND ((data_input_fields.input_output)='in'));
The explain command gives the following output:
+----+-------------+----------------------+--------+--------------------------+---------+---------+----------------------------------------------------+--------+------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------------------+--------+--------------------------+---------+---------+----------------------------------------------------+--------+------------------------------+
| 1 | SIMPLE | graph_templates | const | PRIMARY | PRIMARY | 3 | const | 1 | Using index; Using temporary |
| 1 | SIMPLE | data_input_data | ref | PRIMARY,t_value | t_value | 5 | const | 216 | Using where |
| 1 | SIMPLE | data_input_fields | eq_ref | PRIMARY,data_input_id | PRIMARY | 3 | cacti_lan_db.data_input_data.data_input_field_id | 1 | Using where |
| 1 | SIMPLE | data_template_data | eq_ref | PRIMARY,data_template_id | PRIMARY | 3 | cacti_lan_db.data_input_data.data_template_data_id | 1 | Using where |
| 1 | SIMPLE | graph_templates_item | ALL | graph_template_id | NULL | NULL | NULL | 156112 | Using where; Distinct |
| 1 | SIMPLE | data_template_rrd | eq_ref | PRIMARY,data_template_id | PRIMARY | 3 | cacti_lan_db.graph_templates_item.task_item_id | 1 | Using where; Distinct |
+----+-------------+----------------------+--------+--------------------------+---------+---------+----------------------------------------------------+--------+------------------------------+
6 rows in set (0.00 sec)
my first idea was to setup an index on graph_templates_item.graph_template_id, but it was already set...
is there a sql guru out which can give a hot hint on this?
any ideas are highly welcome!
thanks in advance,
tom
as Alice already pointed out the following query takes approx. 10-14 seconds to return results (found in the slow-query-log):
SELECT DISTINCT data_input_fields.data_name AS `name`, data_input_fields.name AS `description`, data_input_data.value AS `default`, data_template_data.data_template_id, data_input_fields.id AS `data_input_field_id` FROM data_input_data INNER JOIN (((data_template_rrd INNER JOIN (graph_templates INNER JOIN graph_templates_item ON graph_templates.id = graph_templates_item.graph_template_id) ON data_template_rrd.id = graph_templates_item.task_item_id) INNER JOIN data_template_data ON data_template_rrd.data_template_id=data_template_data.data_template_id) INNER JOIN data_input_fields ON data_template_data.data_input_id=data_input_fields.data_input_id) ON (data_input_data.data_template_data_id = data_template_data.id) AND (data_input_data.data_input_field_id = data_input_fields.id) WHERE (((graph_templates.id)=2) AND ((data_input_data.t_value)='on') AND ((data_input_fields.input_output)='in'));
The explain command gives the following output:
+----+-------------+----------------------+--------+--------------------------+---------+---------+----------------------------------------------------+--------+------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------------------+--------+--------------------------+---------+---------+----------------------------------------------------+--------+------------------------------+
| 1 | SIMPLE | graph_templates | const | PRIMARY | PRIMARY | 3 | const | 1 | Using index; Using temporary |
| 1 | SIMPLE | data_input_data | ref | PRIMARY,t_value | t_value | 5 | const | 216 | Using where |
| 1 | SIMPLE | data_input_fields | eq_ref | PRIMARY,data_input_id | PRIMARY | 3 | cacti_lan_db.data_input_data.data_input_field_id | 1 | Using where |
| 1 | SIMPLE | data_template_data | eq_ref | PRIMARY,data_template_id | PRIMARY | 3 | cacti_lan_db.data_input_data.data_template_data_id | 1 | Using where |
| 1 | SIMPLE | graph_templates_item | ALL | graph_template_id | NULL | NULL | NULL | 156112 | Using where; Distinct |
| 1 | SIMPLE | data_template_rrd | eq_ref | PRIMARY,data_template_id | PRIMARY | 3 | cacti_lan_db.graph_templates_item.task_item_id | 1 | Using where; Distinct |
+----+-------------+----------------------+--------+--------------------------+---------+---------+----------------------------------------------------+--------+------------------------------+
6 rows in set (0.00 sec)
my first idea was to setup an index on graph_templates_item.graph_template_id, but it was already set...
is there a sql guru out which can give a hot hint on this?
any ideas are highly welcome!
thanks in advance,
tom
added one more index -> speed up 50 %
Hello,
I found out if one adds one more index to graph_templates_item table on field 'task_item_id' the query is more fast than before.
without the index the query needs 10 - 14 seconds, with the index the query needs around 6 seconds, which is an improvement of 50 percent...
what I have done:
ALTER TABLE `graph_templates_item` ADD INDEX ( `task_item_id` ) ;
any suggestions on this or more like this?
I`m very interested...
thanks in advance,
best regards,
tom
I found out if one adds one more index to graph_templates_item table on field 'task_item_id' the query is more fast than before.
without the index the query needs 10 - 14 seconds, with the index the query needs around 6 seconds, which is an improvement of 50 percent...
what I have done:
ALTER TABLE `graph_templates_item` ADD INDEX ( `task_item_id` ) ;
any suggestions on this or more like this?
I`m very interested...
thanks in advance,
best regards,
tom
Who is online
Users browsing this forum: No registered users and 2 guests