当前位置:网站首页>Will oracle cardinality affect query speed?
Will oracle cardinality affect query speed?
2022-08-11 03:27:00 【Sir Zhang】
Does oracle cardinality affect query speed?
Accepted answer 1:
The cardinality will affect the optimizer's evaluation of the cost. The simplest example is a query:
select * from test where id=1 and sex='male';
There are separate indexes on both the id and sex fields, and the cardinality of the id column is large and the cardinality of the sex column is small, so the database will give priority to the index on the id column when evaluating the execution plan.The cardinality of the id column is large and the selectivity is good, so the amount of io is small when scanning.The final estimated cost is small.
Other Answer 1:
The cardinality will affect the optimizer's evaluation of the cost. The simplest example is a query:
select * from test where id=1 and sex='male';
There are separate indexes on both the id and sex fields, and the cardinality of the id column is large and the cardinality of the sex column is small, so the database will give priority to the index on the id column when evaluating the execution plan.The cardinality of the id column is large and the selectivity is good, so the amount of io is small when scanning.The final estimated cost is small.
Other Answer 2:
I don't think so, but using bitmap indexes on fields with small cardinality can improve query speed
Standard indexes are implemented by storing sorted index columns and corresponding ROWIDs in the index.If we build a standard index on a column with a small cardinality, it will return a large number of records.
When we create a bitmap index, Oracle will scan the entire table and create a bitmap for each value of the index column.If the content is the same, it will be represented by the same number on the bitmap.At this time, if the cardinality of this field is relatively small, the efficiency will be very high if you need to query the entire field.Because at this time, the database only needs to find out the content with the same number in the bitmap.
Other Answer 3:
Cardinality The number of unique keys (Distinct_keys) in a column. For example, if there is a table with 100W rows, the cardinality of the gender column is 2 (select distinct gender from test), the cardinality of the primary key column is 100W(select distinct mid from test);Selectivity cardinality/percentage of total rows, gender 2/100w * 100% primary key 100%, the higher the selectivity, the better the use of the index 20~30% even if it is relatively high 1, how to judge whether an index is created is goodOr is it bad?It depends on his cardinality and selectivity. If the cardinality is large and the selectivity is large, it is better to use an index.
The change of cardinality affects the selectivity of the index and will definitely affect the query speed.
The above is for personal viewing. If there is something wrong, it is for reference only.
Hope it helps you.If you feel satisfied with the answer, please click Accept, thank you
Other Answer 4:
The speed is not directly related to the full table size.It is related to whether to use an index or not, and to return the number of rows.If it is a primary key query, 10 billion is no problem.I used to have a single table of 10 billion, and the performance was good.Not only primary key queries, but also range queries.
边栏推荐
- Paper Accuracy - 2017 CVPR "High-Resolution Image Inpainting using Multi-Scale Neural Patch Synthesis"
- “顶梁柱”滑坡、新增长极难担重任,阿里“蹲下”是为了跳更高?
- 多商户商城系统功能拆解26讲-平台端分销设置
- Briefly, talk about the use of @Transactional in the project
- How can users overcome emotional issues in programmatic trading?
- watch监听
- Official release丨VS Code 1.70
- VIT 源码详解
- 电力机柜数据监测RTU
- The "top pillar" slides, and new growth is extremely difficult to shoulder the heavy responsibility. Is Ali "squatting" to jump higher?
猜你喜欢
互换性与测量技术——表面粗糙度选取和标注方法
STC8H development (15): GPIO drive Ci24R1 wireless module
树莓派入门(5)系统备份
Summary of debugging skills
Rotary array problem: how to realize the array "overall reverse, internal orderly"?"Three-step conversion method" wonderful array
图解LeetCode——640. 求解方程(难度:中等)
rac备库双节点查询到的表最后更新时间不一致
VIT 源码详解
你不知道的 console.log 替代品
按摩椅控制板的开发让按摩椅变得简约智能
随机推荐
Qnet Weak Network Test Tool Operation Guide
7 sorting algorithms that are often tested in interviews
Is Redis old?Performance comparison between Redis and Dragonfly
Kubernetes集群搭建Zabbix监控平台
[yu gong series] Go program 035-08 2022 interfaces and inheritance and transformation and empty interface
The solution to the height collapse problem
Talk about the understanding of RPC
学编程的第十三天
互换性与测量技术——表面粗糙度选取和标注方法
"How to kick a bad habit to read notes?
I didn't expect MySQL to ask these...
图解LeetCode——640. 求解方程(难度:中等)
按摩椅控制板的开发让按摩椅变得简约智能
Paper Accuracy - 2017 CVPR "High-Resolution Image Inpainting using Multi-Scale Neural Patch Synthesis"
QueryDet:级联稀疏query加速高分辨率下的小目标检测
你不知道的 console.log 替代品
C语言之自定义类型------结构体
增加对 Textbundle 的支持
云平台下ESB产品开发步骤说明
What has programmatic trading changed?