慢的:
explain analyze
select c.* from tb_card c use index (PRIMARY )
where (c.c_org_id = ‘8’ and c.c_cardno>‘210007040764’ and c.c_cardno<‘210008913257’ )
and c.c_cardno like repeat(’’,length(‘210008913257’));
id |estRows |actRows|task |access object |execution info |operator info |memory |disk|
-------------------------±----------±------±--------±-----------------------------------------±------------------------------------------------------------------------------------------------------------------------------------------------------------------------±--------------------------------------------------------------±------------------±—+
IndexLookUp_8 |11331358.40|1382934|root | |time:2.531820843s, loops:1352, rpc num: 4, rpc max:361.981307ms, min:166.707005ms, avg:241.492225ms, p80:361.981307ms, p95:361.981307ms, proc keys max:502465, p95:502465| |65.9934778213501 MB|N/A |
├─Selection_7(Build) |11331358.40|1382934|cop[tikv]| |proc max:318ms, min:148ms, p80:318ms, p95:318ms, iters:1369, tasks:4 |like(enjoycrm.tb_card.c_cardno, "__________", 92) |N/A |N/A |
│ └─IndexRangeScan_5 |11378714.35|1382934|cop[tikv]|table:c, index:PRIMARY(c_org_id, c_cardno)|proc max:269ms, min:128ms, p80:269ms, p95:269ms, iters:1369, tasks:4 |range:(“8” “210007040764”,“8” “210008913257”), keep order:false|N/A |N/A |
└─TableRowIDScan_6(Probe)|11331358.40|1382934|cop[tikv]|table:c |proc max:223ms, min:0s, p80:43ms, p95:83ms, iters:5029, tasks:994 |keep order:false |N/A |N/A |
快的:
explain analyze
select c.* from tb_card c use index (IX_tb_card_org )
where (c.c_org_id = ‘8’ and c.c_cardno>‘210007040764’ and c.c_cardno<‘210008913257’ )
and c.c_cardno like repeat(’’,length(‘210008913257’));
id |estRows |actRows|task |access object |execution info |operator info |memory |disk|
-------------------------±----------±------±--------±------------------------------------------------±----------------------------------------------------------------------------------------------------------------------------------------------------------------------±--------------------------------------------------------------±-------------------±—+
IndexLookUp_8 |11331358.40|1382934|root | |time:3.063540656s, loops:1352, rpc num: 3, rpc max:508.369772ms, min:2.940506ms, avg:293.591546ms, p80:508.369772ms, p95:508.369772ms, proc keys max:795138, p95:795138| |64.17386627197266 MB|N/A |
├─Selection_7(Build) |11331358.40|1382934|cop[tikv]| |proc max:440ms, min:0s, p80:440ms, p95:440ms, iters:1364, tasks:3 |like(enjoycrm.tb_card.c_cardno, “____________”, 92) |N/A |N/A |
│ └─IndexRangeScan_5 |14164198.00|1382934|cop[tikv]|table:c, index:IX_tb_card_org(c_org_id, c_cardno)|proc max:373ms, min:0s, p80:373ms, p95:373ms, iters:1364, tasks:3 |range:(“8” “210007040764”,“8” “210008913257”), keep order:false|N/A |N/A |
└─TableRowIDScan_6(Probe)|11331358.40|1382934|cop[tikv]|table:c |proc max:279ms, min:0s, p80:48ms, p95:92ms, iters:4921, tasks:968 |keep order:false |N/A |N/A |