Home > database >  A simple query index doesn't work
A simple query index doesn't work

Time:10-21

 
SELECT SUM (UcAmount) FROM memb_capitaldetail WHERE 1=1
='07 d81732 and UserId - be1b - 41 e2 - a7d4 - aad60161ee36'

SELECT count (UcAmount) FROM memb_capitaldetail WHERE 1=1
='07 d81732 and UserId - be1b - 41 e2 - a7d4 - aad60161ee36'

SELECT count (UserId) FROM memb_capitaldetail WHERE 1=1
='07 d81732 and UserId - be1b - 41 e2 - a7d4 - aad60161ee36'
AND InComeStatus=1

SELECT count (UserId) FROM memb_capitaldetail WHERE 1=1
='07 d81732 and UserId - be1b - 41 e2 - a7d4 - aad60161ee36'

I'm memb_capitaldetail give UserId indexed, but with expain found that only the last to leave the index, the other is a full table scan,
Excuse me, what reason is this?
thank you

CodePudding user response:

Table structure and explain all posted

CodePudding user response:

reference 1st floor csdn_castiel response:
table structure and explain all post

Roughly know the reason, the data on the user's ID found to nearly 40000, a total of 160000 data

CodePudding user response:

reference 1st floor csdn_castiel response:
table structure and explain all post

Roughly know the reason, the data on the user's ID found to nearly 40000, a total of 160000 data, it should be
Check if I switch to only one of only a few hundred really gone,

CodePudding user response:

UserId on the same record too many, generally the same value by more than 20% MYSQL wouldn't walk index, instead of a full table scan directly,
  • Related