So, I have a query that looks like this:
SELECT col1, col2, col3 ... FROM action_6_members m LEFT JOIN action_6_5pts f ON f.member_id = m.id LEFT JOIN action_6_10pts t ON t.member_id = m.id LEFT JOIN action_6_weekly w ON w.member_id = m.id WHERE `draw_id` = '1' ORDER BY m.id DESC LIMIT 0, 20;
now it makes a massive connection (3.5 million * 40 thousand * 20 thousand)
so my idea was this:
do SELECT * FROM action_6_members WHERE draw_id = '1' ORDER BY id DESC LIMIT 0, 20;
then let's move on to this using php to build $in = "IN(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)" ;
then run select * from action_6_5pts where member_id in $in
select * from action_6_10pts where member_id in $in
select * from action_6_weekly where member_id in $in
then combine them all together using php,
this means that although I use four different queries, I select only 20 rows from each, instead of making a connection at all.
Will I notice a significant performance bonus?
RefreshSo, the general consensus is that "DO NOT IT!"
here is a general overview of the application
he gets the code
the code is either 5pt, 10pt, or a weekly code,
all three types of code are in separate tables. three tables have a code, and member_id
references member_id to the identifier in the table action_6_members.
when the code is declared, the data is filled in the table action_6_members.
the identifier of this element is then populated in the table for the requested code.
The above query selects the first twenty members.
So my question.
What can I do to improve this?
since everything is being synchronized until the requests are completed.
action_6_members
CREATE TABLE `action_6_members` ( `id` int(11) NOT NULL auto_increment, `draw_id` int(11) NOT NULL, `mobile` varchar(255) NOT NULL, `fly_buys` varchar(255) NOT NULL, `signup_date` datetime NOT NULL, `club` int(11) NOT NULL default '0' COMMENT '1 = yes, 2 = no', PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=1337 DEFAULT CHARSET=latin1
action_6_ 5 and 10pts
CREATE TABLE `action_6_5pts` ( `code` varchar(255) NOT NULL, `member_id` int(11) NOT NULL, PRIMARY KEY (`code`), KEY `member_id` (`member_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1
action_6_weekly
CREATE TABLE `action_6_weekly` ( `id` int(11) NOT NULL auto_increment, `code` varchar(255) NOT NULL, `member_id` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`), KEY `member_id` (`member_id`) ) ENGINE=MyISAM AUTO_INCREMENT=3250001 DEFAULT CHARSET=latin1
Update 2: request explanation id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE m ALL \ N \ N \ N \ N 1390 Using temporary; Using filesort
1 SIMPLE f ALL member_id \ N \ N \ N 36000
1 SIMPLE t ALL member_id \ N \ N \ N 18000 Using where
1 SIMPLE w ref member_id member_id 4 m.id 525820 Using where
It just happened through: Recent download data from the database 7.26, 4.60, 2.45
1.0 is the normal maximum load ... All of the above means that it must “break” and cause additional processes to be processed. those. 7.26 means the load is 7 x the maximum blade server and he had to call others to help
so now this request is more than a monster, it is eaten by monsters as snacks ...