Home > Back-end >  Refer to how to construct the SQL index
Refer to how to construct the SQL index

Time:09-25

Select IFNULL (i.i smanager, 1), u.m yIntoID, u.t opRecommend, u.i sManages, i.com missionPoints, i.m oney as imoney and i.i d as iid, i. tatus as istatus, o.p ayStatus, o.e ndDate, o.o rdernum, o.a ccountMoney, o.y ly, o.i nvestTime, o.i nvestType, o.p ayTime, ud. Position_type, u.r ealName, u.u serName, u.u serid, u.j gid, u1. RealName as mzfrealName, u1. Userid as u1userid
The from order_data. Data_orders as o
Left the join billstable_data. Data_inexpenses as I on i.o rdernum=o.o rdernum
Left the join members_data. Data_users as u on u.u serid=o.u serid
Left the join members_data. Data_users as u1 on (o.i mportid=u1. Userid or u.t opRecommend=u1. Userid)
Left the join members_data. Data_user_detail AS ud ON u.u serid=ud. Userid
Where o.p ayTime & gt;=849369600 and o.p ayTime & lt;=1451577599
And ((u1. IsManages=1 and o.i nDate & gt; U1. BecomeManageTime) or (u.i sManages=1 AND o.i nDate & gt; U.b ecomeManageTime))
And o.p ayStatus=2 and IFNULL (i.i smanager, 1) & lt;> '0'
Group by o.o rdernum
The ORDER by desc o.i d limit of 90000

CodePudding user response:

Now the problem has nothing to do with the index!

If you really want to build indexes, the standard SQL is the CREATE INDEX command, specific methods and database related

CodePudding user response:

In fact most of the time is not indexed in the program, because most of the time is a library and table design by manager, designer index, in addition to the dynamic table to dynamic index is established

CodePudding user response:

Key to this query is too slow, do not know how to optimize the better.

CodePudding user response:

Can be indexed in the design of the SQL server list, don't have to write the create index, in the where clause of the first condition index is built on the field is the paytime, you can use the "display implementation plan", you can see which step spends much of her time, in spend time more index is built on the table
  • Related