| MySQL Replication [message #853] |
Mon, 05 March 2007 00:32  |
LinuxFreak Messages: 11 Registered: March 2007 Location: Pakistan |
Junior Member |
|
|
Dear Peter,
Hello,
I am working for a company which have huge traffic on their website. They have huge Database and using MySQL Replication.
REPLICATION MYSQL SERVER A
REPLICATION MYSQL SERVER B
REPLICATION MYSQL SERVER C ----> WEBSITE <---> MASTER MYSQL SERVER
REPLICATION MYSQL SERVER D
REPLICATION MYSQL SERVER E
Now, ALL SELECT's statements executed from SERVER A,B,C,D,E and ALL INSERT,DELETE,UPDATE,CREATE,DROP's statements executed from MASTER MYSQL SERVER.
The problem is there will be very high load on SERVER A,B,C,D,E. Can you please help me with that. Please ask me if you need any info.
Best Regards.
Farrukh Ahmed
|
|
|
| Re: MySQL Replication [message #854 is a reply to message #853 ] |
Mon, 05 March 2007 04:16   |
Peter Messages: 405 Registered: August 2006 |
Senior Member Super Guru |
|
|
I'm not sure what your question has to do with MySQL Replication.
you have high load on your severs, I assume from MySQL you need to check MySQL settings and most important queries you're running to see if you can optimize them. Check EXPLAIN statement for the queries to start with.
Peter Zaitsev, MySQL Performance Expert
MySQL Performance Blog - http://www.mysqlperformanceblog.com
MySQL Consulting http://www.mysqlperformanceblog.com/mysql-consulting/
|
|
|
| Re: MySQL Replication [message #855 is a reply to message #854 ] |
Mon, 05 March 2007 06:07   |
LinuxFreak Messages: 11 Registered: March 2007 Location: Pakistan |
Junior Member |
|
|
Dear Peter,
Hello,
This is an example query which took 13.48 Seconds to EXECUTE and when there 40 to 50 queries then server load spikes to 120.
We have Dual Xeon 3.6 GHz with 4 GB of RAM on this replication node.
mysql> EXPLAIN SELECT keyword AS title, rank, ondate
-> FROM (SELECT * FROM seo_keyword_report
-> WHERE (rank /10) >1
-> ORDER BY ondate DESC
-> )keywords
-> GROUP BY keyword
-> ORDER BY rank ASC
-> limit 4,0;
+----+-------------+-----------------------------+------+--- ------------+------+---------+------+--------+-------------- -------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------------------------+------+--- ------------+------+---------+------+--------+-------------- -------------------+
| 1 | PRIMARY | <derived2> | ALL | NULL | NULL | NULL | NULL | 233308 | Using temporary; Using filesort |
| 2 | DERIVED | seo_keyword_report | ALL | NULL | NULL | NULL | NULL | 389861 | Using filesort |
+----+-------------+-----------------------------+------+--- ------------+------+---------+------+--------+-------------- -------------------+
2 rows in set (13.48 sec)
Best Regards.
Farrukh Ahmed
|
|
|
|
|
| Re: MySQL Replication [message #858 is a reply to message #857 ] |
Mon, 05 March 2007 06:23   |
LinuxFreak Messages: 11 Registered: March 2007 Location: Pakistan |
Junior Member |
|
|
Dear Peter,
Hello,
Can you please give me an better example of above query which i have mentioned.
Best Regards.
Farrukh Ahmed
|
|
|
| Re: MySQL Replication [message #859 is a reply to message #855 ] |
Mon, 05 March 2007 08:10   |
Peter Messages: 405 Registered: August 2006 |
Senior Member Super Guru |
|
|
You can do something like:
select * from seo_keyword_report where rank>0.1 group by keyword order by rank ask limit 4
I'm not sure what you have your derived table for at all.
But in general you need to normalize the data so you do not need to do group by keyword in this case you can do it fast.
Peter Zaitsev, MySQL Performance Expert
MySQL Performance Blog - http://www.mysqlperformanceblog.com
MySQL Consulting http://www.mysqlperformanceblog.com/mysql-consulting/
|
|
|
| Re: MySQL Replication [message #860 is a reply to message #853 ] |
Mon, 05 March 2007 08:24   |
LinuxFreak Messages: 11 Registered: March 2007 Location: Pakistan |
Junior Member |
|
|
Dear Peter,
Hello,
I am pasting you describe of my tables;
mysql> describe seo_keyword_report;
+------------------+------------------+------+-----+-------- -------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+------------------+------+-----+-------- -------------+----------------+
| id | int(11) | | PRI | NULL | auto_increment |
| keyword | varchar(255) | | MUL | | |
| search_engine | varchar(255) | | | | |
| rank | int(11) | YES | | NULL | |
| url | tinytext | | | | |
| competetion | int(10) unsigned | | | 0 | |
| ondate | timestamp | YES | | 0000-00-00 00:00:00 | |
+------------------+------------------+------+-----+-------- -------------+----------------+
7 rows in set (0.00 sec)
and indexes on this table
mysql> show index from seo_keyword_report;
+-----------------------------+------------+------------+--- -----------+-------------+-----------+-------------+-------- --+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-----------------------------+------------+------------+--- -----------+-------------+-----------+-------------+-------- --+--------+------+------------+---------+
| seo_keyword_report | 0 | PRIMARY | 1 | id | A | 389883 | NULL | NULL | | BTREE | |
| seo_keyword_report | 1 | keyword | 1 | keyword | A | 129961 | NULL | NULL | | BTREE | |
+-----------------------------+------------+------------+--- -----------+-------------+-----------+-------------+-------- --+--------+------+------------+---------+
2 rows in set (0.00 sec)
The problem is when i removed ORDER BY ondate DES and ORDER BY rank ASC then this query will return results in seconds but we need latest date result for which we need to use ORDER BY ondate DES and also we need rank in ascending order so we have to use this ORDER BY rank ASC
Best Regards.
Farrukh Ahmed
|
|
|
|
| Re: MySQL Replication [message #862 is a reply to message #853 ] |
Mon, 05 March 2007 08:42   |
LinuxFreak Messages: 11 Registered: March 2007 Location: Pakistan |
Junior Member |
|
|
Dear Peter,
Hello,
I used this query manually but its giving me an error.
mysql> select title AS keyword, rank, ondate from seo_keyword_report where rank>10 sort by rank,date;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sort by rank,date' at line 1
Best Regards.
Farrukh Ahmed
|
|
|
|