Home > database >  Time how query optimization, with detail, great spirit to solve the trouble
Time how query optimization, with detail, great spirit to solve the trouble

Time:09-28

The SQL statement: select * from ` looktime ` where lookclassi='9' and looktime between '1519228800' and '1521647999'

This query is a field of a month's time, so that the query will become much slower than direct query,


This is a query within one month of time, much faster than figure 1


In figure 2, by contrast, the data also play than figure 1, why is slower than the figure 2, figure 1

Figure 1 query must be again, what can the SQL optimization, query speed, speed, hope, can solve the great god, thank you very much,

CodePudding user response:

Looktime indexed?

CodePudding user response:

Look at the table structure
Show create table ` looktime `;

CodePudding user response:

Index should be a problem, see lookclassi fields below can be null, whether to have joint index

CodePudding user response:

reference alex259 reply: 3/f
index should be a problem, see lookclassi fields below can be null, whether to have joint index


Two fields are indexed, if query lookclassi alone, it is same as shown in figure 2

CodePudding user response:

reference 1st floor wandier response:
looktime indexed?


Are established

CodePudding user response:

refer to the second floor ZJCXC response:
see table structure
Show create table ` looktime `;


Excuse me, this is what meaning, a bit not understand

CodePudding user response:

reference 5 floor as1504554495 reply:
Quote: refer to 1st floor wandier response:

Looktime indexed?


Have established

Looktime field index to distinguish more, after put in the where condition is better

CodePudding user response:

refer to 7th floor wandier response:
Quote: refer to the fifth floor as1504554495 reply:
Quote: refer to 1st floor wandier response:

Looktime indexed?


Have established

Looktime field index to distinguish the degree is bigger, in the where condition after better




No, is still the same time

CodePudding user response:

Have a great god answer, ask for help

CodePudding user response:

No great god answer
  • Related