Open hanfei1991 opened 3 years ago
The basic idea sounds good to me. How other databases perform this operation? Do they have a similar SQL syntax?
@zz-jason I'm not sure. I figure the similar issues only happens on the dbs which supports multiple isolated engines. They are deployed on different machines, with different types of disks or net cards. I think it's rare in open-source databases; anyway we can dive into it further.
Got it. I think we need more investigation before accepting this feature request. Suggestions are welcomed.
Feature Request
Is your feature request related to a problem? Please describe:
There are some cases that can't choose right storage enigne, like(table name is censored) :
explain analyze SELECT SUM(amount) FROM XXXXXX WHERE shop_id=140193611;
There is an index with columnshop_id
. As a result , cbo selects IndexLookUpBut If we choose to read TiFlash by hint, it only takes 5.77 seconds.
Describe the feature you'd like:
As described, although the scan amounts in TiFlash is 100 times larger than TiDB index, it still takes 100 times less time than TiDB takes. Incorrect default factor has a great nagetive impacts on cbo selections. Surely we can adjust cbo factor case by case, but as the supported operators grow more and more in different engines. Should we continue to set cbo factor according to experieces instead of experiments ?
In order to address this issue, we should provide an new statement as
adjust cbo factor automatically
; then run a series of benchmark statement to compare the speed amongtablescan
,index scan
,index look up
andtiflash scan
, includingindex join
,hash join
andtiflash broadcast join
.Describe alternatives you've considered:
Indeed , our aim is to prevent a worse plan chosen by cbo automatically. Once it happens, we should provide user some approches to tell optimizer "For a certain statement, please choose this plan". We can do this like
explain designate plan [sql statement with hint]
Teachability, Documentation, Adoption, Migration Strategy: