• sql
  • sql-server

2 votes

Pedro Sanchez avatar

What are the indexes used in SQL server?

I was watching a tutorial, but only limit myself to say that are used to optimize searches in the data.

Could someone explain to me the function of all the indices with a practical example?

Nor understood as it is exactly the representation

An index is made up of a set of pages (index nodes) that are organized in a B-tree structure. This structure is hierarchical in nature, with the root node at the top of the hierarchy and the leaf nodes at the bottom

Source: https://www.red-gate.com/simple-talk/sql/learn-sql-server/sql-server-index-basics/

Does that tree of which he speaks is the representation in memory of the indices that we have in the database? and how do we determine the hierarchy of that tree? that is why a node should be the root with respect to another?

Finally, what Varies the role of the indices according to the database system?, Could vary according to the version of the system also?

Answer

Too many ads?

4voto

Luis Cazares Points 1088

The theme of the indices is one very broad that varies between each manager's data base. This answer is fully focused on SQL Server since that is the handle that question.

There are many types of indexes in SQL Server, but we can speak of 2 main clustered and non-clustered. The first are the primary indexes and basically create a key for logically arranging the table. The clustered index is converted, therefore, into the same table. The general rule is that all tables in a database have a clustered index that will be the main form of access to the tables.

The indexes have a tree-structured search balanced so-called b-tree. Is represented in the following manner for the indexes to clustered. introducir la descripción de la imagen aquí

The information in the table is found up to the level of the "leaves", while the roots and intermediate levels only have the key and a pointer.

The indexes non-clustered are indexes auxiliaries which serve only to gather information more quickly when you do not query a table for your clustered index. The indexes non-clustered have a similar structure to the index clustered, but instead of having the table information in the nodes of leaves, have a pointer to the clustered index or to the page where the row (when there is not a clustered index).

The relationship between both types of indices is presented as well, with a clustered index on the left side and one non-clustered on the right side which points to the clustered index: introducir la descripción de la imagen aquí

The indexes non-clustered can have additional columns that are not part of the key to avoid having to read them from the table.

Both types of indices also support to maintain the primary keys or the keys unique.

To finish explain a little, the indexes will help to find a row or set of rows more quickly without having to traverse the entire table. In the same way that we can find a word faster in the dictionary thanks to found in order and don't have to read everything (this is an example of how the indices clustered), or how we can find words in a table of contents of a book that will tell us on which page we can find the theme that we seek to (so make the index non-clustered).

This is just an introduction, since we don't touch the indexes with filter, XML indexes, columnstore, full text, etc

tweet

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

View in original language

Powered by:

Yandex
X

代做工资流水公司莆田打银行流水账单临沂办理入职流水开公司银行流水德阳转账银行流水代做济宁工资流水代办肇庆代开购房银行流水合肥签证银行流水 代开威海代做银行流水账单银川薪资流水单打印遵义背调银行流水代开常州开贷款银行流水潮州背调工资流水代开遵义工作收入证明制作济南查询贷款流水银川银行流水费用岳阳工资流水办理南京打转账银行流水宿迁办理银行流水北京工资流水制作宁波自存流水模板中山背调工资流水图片贵阳流水单查询湖州企业流水打印开具流水单多少钱太原消费贷流水办理舟山贷款工资流水 查询潍坊打印银行流水单扬州银行流水修改费用德阳流水价格衡阳车贷银行流水 样本香港通过《维护国家安全条例》两大学生合买彩票中奖一人不认账让美丽中国“从细节出发”19岁小伙救下5人后溺亡 多方发声卫健委通报少年有偿捐血浆16次猝死汪小菲曝离婚始末何赛飞追着代拍打雅江山火三名扑火人员牺牲系谣言男子被猫抓伤后确诊“猫抓病”周杰伦一审败诉网易中国拥有亿元资产的家庭达13.3万户315晚会后胖东来又人满为患了高校汽车撞人致3死16伤 司机系学生张家界的山上“长”满了韩国人?张立群任西安交通大学校长手机成瘾是影响睡眠质量重要因素网友洛杉矶偶遇贾玲“重生之我在北大当嫡校长”单亲妈妈陷入热恋 14岁儿子报警倪萍分享减重40斤方法杨倩无缘巴黎奥运考生莫言也上北大硕士复试名单了许家印被限制高消费奥巴马现身唐宁街 黑色着装引猜测专访95后高颜值猪保姆男孩8年未见母亲被告知被遗忘七年后宇文玥被薅头发捞上岸郑州一火锅店爆改成麻辣烫店西双版纳热带植物园回应蜉蝣大爆发沉迷短剧的人就像掉进了杀猪盘当地回应沈阳致3死车祸车主疑毒驾开除党籍5年后 原水城县长再被查凯特王妃现身!外出购物视频曝光初中生遭15人围殴自卫刺伤3人判无罪事业单位女子向同事水杯投不明物质男子被流浪猫绊倒 投喂者赔24万外国人感慨凌晨的中国很安全路边卖淀粉肠阿姨主动出示声明书胖东来员工每周单休无小长假王树国卸任西安交大校长 师生送别小米汽车超级工厂正式揭幕黑马情侣提车了妈妈回应孩子在校撞护栏坠楼校方回应护栏损坏小学生课间坠楼房客欠租失踪 房东直发愁专家建议不必谈骨泥色变老人退休金被冒领16年 金额超20万西藏招商引资投资者子女可当地高考特朗普无法缴纳4.54亿美元罚金浙江一高校内汽车冲撞行人 多人受伤

代做工资流水公司 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化