Home > database >  Request to optimize, the execution time is too long
Request to optimize, the execution time is too long

Time:09-28

Thought is not very complex statements, but the execution time is very long, statement execution is 7 s, alone in the stored procedure execution is 44 s, really can't accept it.
Statement execution is
 SELECT 
A.s exs AS sex,
IFNULL (p. ercentage, 0) AS percentage with
The FROM (
SELECT the 'male' AS sexs
UNION ALL
SELECT the 'female'
) a
LEFT the JOIN
(
SELECT
P. EX,
COUNT (1)
(15315) AS percentage with
The FROM player_login_logout_log A
LEFT the JOIN player_create_log P ON a. ` role_id `=P.R OLE_ID
WHERE player_state='login'
- AND IF - (_system_type IS NULL, 0=0, a.s ystem_type=_system_type) AND the IF (_platform IS NULL, 0=0, Amy polumbo latform=_platform) AND the IF (_zone_id IS NULL, 0=0, a.z one_id=_zone_id)
AND the LEFT (A.t ime, 10) BETWEEN '2018-04-01' AND '2018-04-30 s'
GROUP BY p. EX

B) ON a.s exs=b.s ex;

The execution plan is really don't know  red circle is how to

CodePudding user response:

Player, the two form the index of the situation, said

CodePudding user response:

reference 1st floor wmxcn2000 response:
player, said the index of two tables, the

Is this table player_login_logout_log index is such A
Table player_create_log P index is the
Hope your help.

CodePudding user response:

Two tables should be simple, don't go index, large amount of data must be slow,

LEFT the JOIN player_create_log P ON a. ` role_id `=P.R OLE_ID
The P table role_id try to build an index

The simplest is analyzed, in SSMS, right click and choose "contains the actual implementation plan"
Go take a look at what the index, can not understand screenshots to look at it
  • Related