当前位置:网站首页>Bi-sql index
Bi-sql index
2022-06-23 21:06:00 【Powerbi white tea】
INDEX
INDEX, Indexes . Index is one of the advanced skills in data warehouse , And a lot of HR What I like to ask in an interview .
Indexes can be used to sort data , And use this to speed up search and sorting .
This and SUBSTITUTEWITHINDEX function It's kind of like . White tea said before when describing this function , This function belongs to one of the higher order functions , The appearance rate is not very high , Only specific scenarios can be used .
This and SQL Medium INDEX It's kind of similar , It is usually used to add index columns to the original dimension columns , To facilitate the calculation of dimensions at certain times , The original text information can be converted into numerical values that can participate in the calculation .
And in the SQL in ,INDEX The performance is more pure .
Basic grammar
CREATE INDEX The index name ON The name of the table ( Name 1, Name 2...) -- We can set the index according to a dimension , It can be multiple
matters needing attention
- INDEX It can speed up the query , But it will increase the maintenance work . for example : Attention should be paid to the addition, deletion and modification of INDEX Dynamic update of .
- INDEX Will increase storage space .
- Some data are not suitable for indexing , For example, the provinces of our country , Not much data .
- Data that is often used as the basis for sorting , Suitable for indexing .
Interview scene : Database index is invalid , What are the possible reasons ? answer : It may be when the data changes , No maintenance updates to the index .
Using examples
Case data :
In the database of white tea machine , There is a name “TEST” The database of , There is a name “ Product list ” Case data for .
Example 1:
According to the trade name , Add a new column INDEX.
CREATE INDEX Product_INDEX ON Product list ( Name of commodity )
give the result as follows :
Example 2:
According to the trade name , Add a new column INDEX, Duplicate entries are not allowed in the index .
CREATE UNIQUE INDEX Product_DIS_INDEX ON Product list ( Name of commodity )
give the result as follows :
Example 3:
According to the trade name , Add a new column INDEX, Duplicate entries are not allowed in the index , And it needs to be in descending order according to the product name .
CREATE UNIQUE INDEX Product_DESC_INDEX ON Product list ( Name of commodity DESC)
give the result as follows :
Example 4:
According to the commodity name and commodity classification , Add a new column INDEX, Duplicate entries are not allowed in the index .
CREATE UNIQUE INDEX GroupSort ON Product list ( Name of commodity , Classification of goods )
give the result as follows :
边栏推荐
- [golang] delving into strings -- from byte run string to unicode and UTF-8
- 【Debian】Debian使用笔记
- Does the fortress machine need a server? Understand the architectural relationship between fortress machine and server
- [golang] type conversion summary
- 100 lines of code, using pyGame to make a snake game!
- How do I close and restore ports 135, 139 and 445?
- 游戏安全丨喊话CALL分析-写代码
- Copilot - employee, your layoff notice has been delivered
- What is the difference between a database and a cloud disk drive? What functions can cloud disk drives achieve?
- How to deal with unclear pictures? What are the techniques for taking clear pictures?
猜你喜欢
随机推荐
How to dispose of the words on the picture? How do I add text to a picture?
How to build a personal cloud game server? How many games can the cloud game platform install?
Fortress deployment server setup operation guide for novices
手续费佣金低的券商,华泰证券网上开户安全吗
Short video intelligent audit software intelligent audit or manual audit
Realize vscode to write markdown documents + pictures to be automatically uploaded to Tencent cloud cos
JS regular ignore case
Cloudbase init considerations
数字电路概述
Using asp Net core MVC framework for building web applications
How does the fortress machine connect to the server? Novice must know operation steps
How to make a commodity price tag
Full instructions for databinding
【Debian】Debian使用笔记
Game security - call analysis - write code
[golang] how to realize real-time hot update of Go program
Is it safe for Huatai Securities to open an account online for securities companies with low handling fees and commissions
How to process the text of a picture into a table? Can the text in the picture be transferred to the document?
Bypass memory integrity check
JS advanced programming version 4: generator learning


