WebsiteBaker Community Forum

General Community => Global WebsiteBaker 2.8.x discussion => Topic started by: Psp on August 24, 2016, 12:05:00 PM

Title: DB - Optimierung
Post by: Psp on August 24, 2016, 12:05:00 PM
Hallo,
weil der Provider meckert über hohe Belastung der MySql Datenbank, mussten wir mal in logs und Variablen gucken. m.E. sind alle Slow-Logs von WB und ich vermute da könnte man einiges optimieren

Code: [Select]
Mysql Status Variable (aus phpMyadmin->Status)
Select full join 192 Anzahl der Joins ohne Schlüssel. Wenn dieser Wert nicht 0 ist sollten die Indizes der Tabellen sorgfältig überprüft werden.
Select full range join 111 Anzahl der Joins, bei denen eine Bereichssuche auf die Referenztabelle statt fand.
Select range               1.6 k Anzahl der Joins, bei denen Bereiche auf die erste Tabelle benutzt wurden. (Es ist normalerweise unkritisch, wenn dieser Wert hoch ist.)
Select range check        168 Anzahl der Joins ohne Schlüssel, bei denen nach jeder Zeile auf Schlüsselbenutzung geprüft wurde. (Wenn dieser Wert nicht 0 ist sollten die Indizes der Tabellen sorgfältig überprüft werden.)
Select scan                34.6 k Anzahl der Joins, bei denen die erste Tabelle gescannt wurde.

im dem Slow-query-Log ist mir dieser Join aufgefallen:
SELECT `p`.`page_id`, `link` FROM `wb_pages` `p` INNER JOIN `wb_sections` USING(`page_id`) WHERE `parent`=0 AND `visibility`='public' AND ((1471874381>=`publ_start` OR `publ_start`=0) AND (1471874381<=`publ_end` OR `publ_end`=0) ) AND `language`='DE' ORDER BY `p`.`position` ASC;
# Time: 160822 15:59:42
# User@Host: root[root] @ localhost []
# Query_time: 1.963119  Lock_time: 0.000116 Rows_sent: 2  Rows_examined: 905
Ich denke mal, da ist noch Luft nach oben - was sagen die Experten?
Gruß
psp
Title: Re: DB - Optimierung
Post by: Ruud on August 24, 2016, 12:21:14 PM
First of all, note that the timestamp, user and querytime are logged above the query.
The long (almost 2 seconds) query was:

Code: [Select]
# Time: 160822 15:59:42
# User@Host: root[root] @ localhost []
# Query_time: 1.963119  Lock_time: 0.000116 Rows_sent: 2  Rows_examined: 905
SET timestamp=1471874382;
SELECT ENGINE,SUM(DATA_LENGTH+INDEX_LENGTH),COUNT(ENGINE),SUM(DATA_LENGTH),SUM(INDEX_LENGTH) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema', 'performance_schema', 'mysql') AND ENGINE IS NOT NULL GROUP BY ENGINE ORDER BY ENGINE ASC;
executed by the root user (your host)
Title: Re: DB - Optimierung
Post by: Psp on August 24, 2016, 01:13:12 PM
Hi Ruud,
I just noticed my error. Yes the very slow query was
Code: [Select]
# Time: 160822 15:59:42
# User@Host: root[root] @ localhost []
# Query_time: 1.963119  Lock_time: 0.000116 Rows_sent: 2  Rows_examined: 905
SET timestamp=1471874382;
SELECT ENGINE,SUM(DATA_LENGTH+INDEX_LENGTH),COUNT(ENGINE),SUM(DATA_LENGTH),SUM(INDEX_LENGTH) FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema', 'performance_schema', 'mysql') AND ENGINE IS NOT NULL GROUP BY ENGINE ORDER BY ENGINE ASC;
Thanx for noticing!
psp