当前位置:网站首页>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.
边栏推荐
猜你喜欢

Ten Advanced Concepts of SQL Development

轮转数组问题:如何实现数组“整体逆序,内部有序”?“三步转换法”妙转数组

QueryDet: Cascading Sparse Query Accelerates Small Object Detection at High Resolution

Rotary array problem: how to realize the array "overall reverse, internal orderly"?"Three-step conversion method" wonderful array

Is Redis old?Performance comparison between Redis and Dragonfly

【Yugong Series】August 2022 Go Teaching Course 036-Type Assertion

Homework 8.10 TFTP protocol download function

Summary of debugging skills

Add user error useradd: cannot open /etc/passwd

AI+Medical: Using Neural Networks for Medical Image Recognition and Analysis
随机推荐
图解LeetCode——640. 求解方程(难度:中等)
flink The object probably contains or references non serializable fields.
The problem that Merge will be lost again after code Revert has been solved
[BX]和loop
云平台下ESB产品开发步骤说明
80端口和443端口是什么?有什么区别?
AI + medical: for medical image recognition using neural network analysis
荣威imax8ev魔方电池安全感,背后隐藏着哪些黑化膨胀?
Window function application of sum and count
Economic Misunderstandings in the Crypto World: Is Cash a Savings?Scarcity creates value?
没想到MySQL还会问这些...
Detailed explanation of VIT source code
What kind of programming trading strategy types can be divided into?
Typescript study notes | Byte Youth Training Notes
浅析一下期货程序化交易好还是手工单好?
作业8.10 TFTP协议 下载功能
树莓派入门(5)系统备份
Qnet弱网测试工具操作指南
Meaning of df and df -lh
"Beijing-Taiwan high-speed rail" debuted on Baidu map, can it really be built in 2035?