Home > database >  Master mysql optimization, view the union query slowly. Please enter!
Master mysql optimization, view the union query slowly. Please enter!

Time:09-25

The CREATE VIEW push_log AS
SELECT the title, id, every, titlepic FROM push_log_0 BETWEEN (UNIX_TIMESTAMP (NOW ()) - (24) (3600 * * 30)) AND UNIX_TIMESTAMP (NOW ()))
The UNION
SELECT the title, id, every, titlepic FROM push_log_1 BETWEEN (UNIX_TIMESTAMP (NOW ()) - (24) (3600 * * 30)) AND UNIX_TIMESTAMP (NOW ()))
The UNION
SELECT the title, id, every, titlepic FROM push_log_2 BETWEEN (UNIX_TIMESTAMP (NOW ()) - (24) (3600 * * 30)) AND UNIX_TIMESTAMP (NOW ()))
The UNION
SELECT the title, id, every, titlepic FROM push_log_3 BETWEEN (UNIX_TIMESTAMP (NOW ()) - (24) (3600 * * 30)) AND UNIX_TIMESTAMP (NOW ()))

The UNION...

Like this UNION query result of mysql view was founded after the connection is slow,, please give a optimization scheme, thank you,

CodePudding user response:

After using union all connections, the union connection, connection will also perform to heavy operation

CodePudding user response:

The union would use the sort, to go to
Look at the query plan, analyze whether can walk index

CodePudding user response:

1/f, the great god to reply a little bit, still can be optimized for 2 seconds, but now the query speed in the 4 to 5 seconds, speed or not, everyone is there some other solutions,

CodePudding user response:

Post the explain the select... For analysis,

CodePudding user response:

I directly in the or, in, and the condition, the union of a batch of slow

CodePudding user response:

"How to implement window functions to assist the MySQL" this article introduces the method, can realize the union query, good problem solving and performance

CodePudding user response:

You put the where condition, into a fixed value, don't use function, first try, whether to change quickly?
  • Related