Home > database >  Shock!!! The query is in the 114 s
Shock!!! The query is in the 114 s

Time:10-06

The SELECT m. * from the message m
INNER JOIN ` case ` c on c.E bayAccountId=m.E bayAccountId
WHERE m.E bayAccountId is not NULL and m.i d> 0
GROUP BY m.E bayAccountId
LIMIT 10;

1 SIMPLE m index PRIMARY IDX_Id_Created, IDX_EbayAccountId_Created IDX_EbayAccountId_Created 149 110 Using the where
1 SIMPLE c ref IX_EbayAccountId_Created IX_EbayAccountId_Created 144 customerservicesystem m.E bayAccountId 176 Using index

Table structure:
The CREATE TABLE ` message ` (
` Id ` char (36) NOT NULL,
` EbayId ` varchar (20) NOT NULL,
` ExternalId ` varchar (100) the DEFAULT NULL,
` Subject ` text NOT NULL,
` Body ` longtext,
` CustomerAccount ` varchar (100) NOT NULL,
` EbayAccountId ` char (36) NOT NULL,
` MessageTime ` datetime NOT NULL,
` EbayItemId ` varchar (20) DEFAULT NULL COMMENT 'ItemNo,
` ItemId ` char (36) DEFAULT NULL COMMENT 'product Id,
` ItemCode ` varchar (50) DEFAULT NULL COMMENT 'product name SKU/SPU,
` ItemType ` int (11) the DEFAULT NULL COMMENT 'product type,
` EbayMessageType ` varchar (50) NOT NULL,
` EbayQuestionType ` varchar (50) NOT NULL,
` IsReceived ` tinyint (4) NOT NULL COMMENT 'to distinguish the source: true: it means the buyer sent the message received, said fase reply message',
` HasReplied ` tinyint (4) NOT NULL COMMENT 'reply is,
` HasRead ` tinyint (4) NOT NULL COMMENT 'is read,
` OwnerId ` char (36) DEFAULT NULL COMMENT 'deal with the ID of the service,
` OwnerName ` varchar (50) DEFAULT NULL COMMENT 'deal with the name of the service,
` Level ` int (11), NOT NULL COMMENT 'levels: Normal: standard, Urgent, Urgent, NoNeedReply: don't have to reply',
` IsAfterSale ` tinyint (4) NOT NULL COMMENT whether after-sales,
` Created ` datetime NOT NULL COMMENT 'records generated date,
` BodyGzip ` longblob,
PRIMARY KEY (` Id `),
The KEY ` IDX_EBAYID ` (` EbayId `),
The KEY ` IDX_OWNERID_ISRECEIVED ` (` OwnerId `, ` IsReceived `),
The KEY ` IX_CustomerAccount ` (` CustomerAccount `),
The KEY ` IX_EbayItemId ` (` EbayItemId `),
The KEY ` IDX_Id_Created ` (` Id `, ` Created `),
The KEY ` IX_ExternalId ` (` ExternalId `),
The KEY ` IDX_Created ` (` Created `),
The KEY ` IDX_EbayAccountId_Created ` (` EbayAccountId `, ` Created `)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CodePudding user response:

The amount of data, check to meet the conditions after the group by the amount of data and the total amount according to
Although there is a limit of 10, but the results of this role in the group by, so if it is a large amount of data, it must be to deal with for a long time
  • Related