当前位置:网站首页>Gbase8s composite index (I)
Gbase8s composite index (I)
2022-07-03 05:01:00 【The heart sea is ordinary】
A simple index is an index created based on a column or function , The corresponding is the composite index . Composite index is also called composite index , That is, the index contains two or more columns .GBase8s The composite index of supports at most 16 Index columns , The total size of columns should be less than 390 bytes.
Examples of composite indexes are as follows :
create index ix_items on items(stock_num,manu_code);An example of a composite index is shown below :

Using composite index can reduce the number of indexes , Enhance the uniqueness of the index , At the same time, it can improve the performance of join query based on multi column combination . for example , Indexes ix_items It can improve the performance of the following query statements :
select * from items where stock_num=2 and manu_code='HSK';meanwhile , You can also use this index for the following queries :
select * from items where stock_num=2;When creating a composite index , We need to consider the order of columns , It should be the order from the most commonly used column to the least commonly used column , The order of discrimination from high to low .
(1) It is necessary to consider the SQL Statement , Which predicates ( That is to say where Columns used by conditions ) Most of the times .
(2) You need to consider the differentiation of columns , The discrimination of a column is the number of all different values in the column . Generally, the columns with high discrimination are placed in front , Put the columns with low discrimination behind . Suppose there is A,B Two ,A The discrimination of is 100000, and B The discrimination of is 10000, Then don't consider other factors , It is recommended to use (A,B).
When the above two conditions conflict , You need to consider the query that is emphasized in the application SQL And the actual test performance results , To determine the order of index columns . The above case, ,A The discrimination of is 100000,B The discrimination of is 10000, Suppose there is 50% Of SQL The statement only uses B Column query ,40% Used A,B Column , Then it is suggested to create (B,A) The order . here , If the application only queries A The performance requirements of columns are high , Then it needs to be considered in A Create a single index on .
For cases with little difference in discrimination , You need to determine the order of the index columns according to the actual test results . See the following GBase8s Composite index ( Two ).
边栏推荐
- Distinguish between releases and snapshots in nexus private library
- [set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)
- Problems encountered in fuzzy query of SQL statements
- Market status and development prospect prediction of the global fire alarm sensor industry in 2022
- Thesis reading_ Chinese medical model_ eHealth
- [research materials] the fourth quarter report of the survey of Chinese small and micro entrepreneurs in 2021 - Download attached
- ZABBIX monitoring of lamp architecture (2): ZABBIX basic operation
- String matching: find a substring in a string
- Market status and development prospects of the global autonomous marine glider industry in 2022
- First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
猜你喜欢

2022-02-11 daily clock in: problem fine brush

Kept hot standby and haproxy

Handling record of electric skateboard detained by traffic police

Silent authorization login and registration of wechat applet

Review the old and know the new: Notes on Data Science

Mobile terminal - uniapp development record (public request encapsulation)

Source insight garbled code solution

"Niuke brush Verilog" part II Verilog advanced challenge

leetcode406. Rebuild the queue based on height

Online VR model display - 3D visual display solution
随机推荐
Problems encountered in fuzzy query of SQL statements
@RequestMapping
Interface frequency limit access
Sprintf formatter abnormal exit problem
第十九届浙江省 I. Barbecue
The reason why the entity class in the database is changed into hump naming
cookie session jwt
[clock 223] [binary tree] [leetcode high frequency]: 102 Sequence traversal of binary tree
I stepped on a foundation pit today
JDBC database operation
Blog building tool recommendation (text book delivery)
移动端——uniapp开发记录(公共请求request封装)
The programmer resigned and was sentenced to 10 months for deleting the code. JD came home and said that it took 30000 to restore the database. Netizen: This is really a revenge
Oracle SQL table data loss
Handling record of electric skateboard detained by traffic police
Concurrent operation memory interaction
Wechat applet waterfall flow and pull up to the bottom
Literature reading_ Research on the usefulness identification of tourism online comments based on semantic fusion of multimodal data (Chinese Literature)
The least operation of leetcode simple problem makes the array increment
Learn to use the idea breakpoint debugging tool