当前位置:网站首页>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.
边栏推荐
- Roewe imax8ev cube battery security, what blackening and swelling are hidden behind it?
- [BX] and loop
- 否定语义转化层
- watch监听
- A practice arrangement about map GIS (below) GIS practice of Redis
- EasyCVR接入GB28181设备时,设备接入正常但视频无法播放是什么原因?
- Qnet Weak Network Test Tool Operation Guide
- JS-DOM element object
- 你不知道的 console.log 替代品
- DNS分离解析和智能解析
猜你喜欢
大马驮2石粮食,中马驮1石粮食,两头小马驮一石粮食,要用100匹马,驮100石粮食,如何分配?
二叉树相关代码题【较全】C语言
调试技巧总结
【愚公系列】2022年08月 Go教学课程 036-类型断言
CSDN 博客更换皮肤
Multi-merchant mall system function disassembly 26 lectures - platform-side distribution settings
I didn't expect MySQL to ask these...
leetcode: 358. Reorder strings at K distance intervals
Ten Advanced Concepts of SQL Development
CSDN blog replacement skin
随机推荐
高度塌陷问题的解决办法
App基本框架搭建丨日志管理 - KLog
"Beijing-Taiwan high-speed rail" debuted on Baidu map, can it really be built in 2035?
按摩椅控制板的开发让按摩椅变得简约智能
KingbaseES有什么办法,默认不读取sys_catalog下的系统视图?
构建程序化交易系统需要注意什么问题?
Ten Advanced Concepts of SQL Development
Homework 8.10 TFTP protocol download function
【愚公系列】2022年08月 Go教学课程 035-接口和继承和转换与空接口
Entity to Vo conversion
Typescript study notes | Byte Youth Training Notes
A Practical Arrangement of Map GIS Development Matters (Part 1)
输入起始位置,终止位置截取链表
Unity2D animation (1) introduction to Unity scheme - animation system composition and the function of use
(Nips-2015)空间变换器网络
Official release丨VS Code 1.70
Detailed explanation of VIT source code
荣威imax8ev魔方电池安全感,背后隐藏着哪些黑化膨胀?
C language recv() function, recvfrom() function, recvmsg() function
Salesforce disbands the Chinese team, which CRM product is more suitable for the Chinese