TiDB SQL query like the test questions

Hands recently had a very core of the new project, the main business undertaking from the old system, the old system is based on Oracle, although the usual amount of concurrency and Internet services is not high compared with, but the complexity of SQL is very high, 5, 6 the associated tables are commonplace. In the group to 'O' background, database options for new projects main consideration NewSQL - TiDB.
Due to the time line of the new project is tight, hope to develop a colleague rectification SQL is impossible, and now the worry point is the performance when executing complex SQL TiDB, recently found such a phenomenon, ignorant at the time of the test, hope to have a big God can answer:
the MySQL [DB1]> SELECT
-> the DISTINCT v.vehicle_no vehicleNo,
-> '2019-05-31 08:59:00' AS expireDate,
-> AS b.batch_name BatchName,
-> r.is_distribute isDistribute,
-> DATE_FORMAT ( r.date_created, 'the MM-dd-YYYY') dateCreated is,
-> r.tmr_id TMRID,
-> t.customer_id the customerId,
-> r.task_group_id taskGroupId,
-> 'Test' AS codeDesc,
-> 'Test' AS robotName ,
-> c.campaign_name campaignName,
-> v.policy_end_date policyEndDate,

-> s.special_dial_org_name specialName,
-> 'test' as secondOrg
-> from t_pub_task t,
-> t_pub_robot_communicate r,
-> t_pub_campaign c,
-> t_pub_batch b left join
-> t_aas_dialorg_custcount_source s on b.tcims_batch_id = s.batch_id,
-> t_pc_vehicle v
-> where r.task_group_id = t.task_group_id
-> and t.vehicle_id is not null
-> and t.vehicle_id = v.nets_vehicle_id
-> and t.batch_id = b.batch_id
-> and t.campaign_id = c.campaign_id
-> and t.team_id = '1000002832'
-> and v.nets_cust_id = t.customer_id
-> and r.list_type = 7
-> and c.biz_model = '1'
-> and r.tmr_id IS NULL
-> AND r.is_distribute = 'N'
-> AND (r.date_created >= date_format('20090531092304', '%Y-%m-%d 00:00:00'))
-> AND (r.date_created < DATE_ADD(date_format('20190531092304', '%Y-%m-%d 00:00:00'), interval 1 day))
-> AND r.robot_id = '22222'
-> AND (C.EXPIRED_DATE = '2011-04')
-> AND b.batch_name like '%test%'
-> AND t.org_id = '201'
-> AND exists (select e.list_rank
-> from t_pub_wx_entry_auto_call e
-> where t.TASK_GROUP_ID = e.task_group_id
-> and e.list_rank = 'A');
Empty set (3.54 sec)


MySQL [db1]> select
-> DISTINCT v.vehicle_no vehicleNo,
-> '2019-05-31 08:59:00' as expireDate,
-> b.batch_name as batchName,
-> r.is_distribute isDistribute,
-> date_format(r.date_created, 'yyyy-MM-dd') dateCreated,
-> r.tmr_id tmrId,
-> t.customer_id customerId,
-> r.task_group_id taskGroupId,
-> 'test' as codeDesc,
-> 'test' as robotName,
-> c.campaign_name campaignName,
-> v.policy_end_date policyEndDate,
-> 'test' as listRank,
-> s.special_dial_org_name specialName,
-> 'test' as secondOrg
-> from t_pub_task t,
-> t_pub_robot_communicate r,
-> t_pub_campaign c,
-> t_pub_batch b left join
-> t_aas_dialorg_custcount_source s on b.tcims_batch_id = s.batch_id,
-> t_pc_vehicle v
-> where r.task_group_id = t.task_group_id
-> and t.vehicle_id is not null
-> and t.vehicle_id = v.nets_vehicle_id
-> and t.batch_id = b.batch_id
-> and t.campaign_id = c.campaign_id
-> and t.team_id = '1000002832'
-> and v.nets_cust_id = t.customer_id
-> and r.list_type = 7
-> and c.biz_model = '1'
-> and r.tmr_id IS NULL
-> AND r.is_distribute = 'N'
-> AND (r.date_created >= date_format('20090531092304', '%Y-%m-%d 00:00:00'))
-> AND (r.date_created < DATE_ADD(date_format('20190531092304', '%Y-%m-%d 00:00:00'), interval 1 day))
-> AND r.robot_id = '22222'
-> AND (C.EXPIRED_DATE = '2011-04')
-> AND b.batch_name like '%t%'
-> AND t.org_id = '201'
-> AND exists (select e.list_rank
-> from t_pub_wx_entry_auto_call e
-> where t.TASK_GROUP_ID = e.task_group_id
-> and e.list_rank = 'A');
Empty set (0.67 sec)

SQL is the above-mentioned two different values of the variable bindings the same SQL
first to b.batch_name like '% test%
second as b.batch_name like'% t%
two SQL execution plan set (after all, only different values ), Article II filter criteria looser, more temporary result set, and normally consumed when the join should be greater than the first, that is the second execution time should be longer, to test the result is the opposite!
Several subsequent tests found that when the value of the like to a plurality of letters (such as 'aa', 'abc', etc.), which performs time in about 3.5s;
When the like to a single value when the letters or Chinese (such as 'a', 'business'), the execution time significantly reduced to about 0.7s, and my perception completely opposite.
In order to determine the problem is not like the query, but also made the following test:
the MySQL [DB1]> SELECT COUNT ( ) from (SELECT batch_name from t_pub_batch WHERE batch_name like '%% T') A;
+ -------- - +
| COUNT (
) |
+ ---------- +
| 25739 |
+ ---------- +
1 Row in the SET (3.05 sec)

The MySQL [DB1]> SELECT COUNT ( ) from (SELECT batch_name from t_pub_batch WHERE batch_name like '%% Test') A;
+ ---------- +
| COUNT (
) |
+ ------ + ----
| 2 |
+ ---------- +
1 Row in the SET (3.04 sec)
found no significant difference when TiDB like query processing efficiency of these two values, that is the problem not out of here in a query like, like '% t% of the result set is indeed much larger, then the question is, what is the reason leading to the above SQL execution times counter-intuitive it? First make a mark, to record the issue, explore answers. .

Guess you like

Origin blog.51cto.com/13476134/2403232