I. Clustered Index
The page level of the clustered index includes the index key and data page. Therefore, the answer to what the leaf level of the clustered index stores besides the key value is everything, that is, all fields in each row are in the leaf level.
Another talk is that data itself is part of the clustered index, which maintains the Data Order in the table based on the key value.
In SQL Server, all clustered indexes are unique,If the unique keyword is not specified when you create a clustered index, SQL Server adds a unique identifier (uniqueifier) to the past record as needed to ensure the uniqueness of the index, the unique identifier is a 4-byte value and is added to the data as a field appended to the clustered index key, only rows declared as index key fields with duplicate values will be added.
Ii. Non-clustered Index
For non-clustered indexes, the leaf level does not contain all the data. In addition to the key value, the index row in each leaf level (the lowest layer of the tree) contains a bookmark to tell SQL server where to locate the data row corresponding to the index key. A bookmarked course can be in two formats. If there is a clustered index on the table, the bookmarks are the clustered index keys of the corresponding data rows. If the table is in a heap structure, that is, if no clustered index is found, the bookmarkdonet is a row identifier, RID, locate the actual row in the format of the file number page number slot number.
The existence or absence of a non-clustered index does not affect the organization of data paging. Therefore, each table is not limited to having a non-clustered index as a clustered index, SQL Server 2005 each table can contain 249 non-clustered indexes SQL Server 2008 each table can contain 999 non-clustered indexes, but actually used less than this number.
Iii. Index inclusion
The maximum number of index key fields is 16, with a total size of 900 bytes. The inclusion column only appears at the leaf level and does not control the sorting of index rows in any way.They aim to enable the leaf level to contain more information so as to make full use of the index optimization capabilities covering the index (covering index. covering indexes is a non-clustered index. You can find all the information that meets the query conditions at the leaf level, so that SQL server does not need to access data pagination at all, in some cases, SQL Serer quietly adds an inclusive column to the index.This may occur when the index is created in the partition table, that is, the blog O (partition _ partition) O (partitioned table) I posted today does not specify on filegroup or no partition_scheme.
I. SQL Server table partition introduction:
The Table Partitioning technology introduced by SQL Server allows users to distribute data to different physical disks, improve the parallel processing performance of these disks to Optimize Query performance ......
2. SQL Server database table partitions are completed in three steps:
1. Create a partition function
2. Create a partition Architecture
3. Partition the table
Based on the cache update mechanism, I use time for partitioning. Here we use suitable fields as partitions according to business requirements.
Number of database partition files created. The data stored for one year is divided into 12 partitions, you need to create a data folder on drive D, which contains the primary folder and FG1 FG2 FG3 fg4 ............
CopyCode The Code is as follows: if exists (Select name from SYS. databases where name = n 'airavcache ')
Drop database [airavcache]
Go
Create Database [airavcache]
On Primary
(Name = 'data partition dB primary fg ',
Filename =
'D: \ data \ primary \ airavcache primary FG. MDF ',
Size = 5,
Maxsize = 500,
Filegrowth = 1 ),
Filegroup [airavcache FG1]
(Name = 'airavcache FG1 ',
Filename =
'D: \ data \ FG1 \ airavcache fg1.ndf ',
Size = 5 MB,
Maxsize = 500,
Filegrowth = 1 ),
Filegroup [airavcache FG2]
(Name = 'airavcache fg ',
Filename =
'D: \ data \ FG2 \ airavcache fg2.ndf ',
Size = 5 MB,
Maxsize = 500,
Filegrowth = 1 ),
Filegroup [airavcache FG3]
(Name = 'airavcache fg3 ',
Filename =
'D: \ data \ FG3 \ airavcache fg3.ndf ',
Size = 5 MB,
Maxsize = 500,
Filegrowth = 1 ),
Filegroup [airavcache fg4]
(Name = 'airavcache fg4 ',
Filename =
'D: \ data \ fg4 \ airavcache fg4.ndf ',
Size = 5 MB,
Maxsize = 500,
Filegrowth = 1 ),
Filegroup [airavcache fg5]
(Name = 'airavcache fg5 ',
Filename =
'D: \ data \ fg5 \ airavcache fg5.ndf ',
Size = 5 MB,
Maxsize = 500,
Filegrowth = 1 ),
Filegroup [airavcache fg6]
(Name = 'airavcache fg6 ',
Filename =
'D: \ data \ fg6 \ airavcache fg6.ndf ',
Size = 5 MB,
Maxsize = 500,
Filegrowth = 1 ),
Filegroup [airavcache fg7]
(Name = 'airavcache fg7 ',
Filename =
'D: \ data \ fg7 \ airavcache fg7.ndf ',
Size = 5 MB,
Maxsize = 500,
Filegrowth = 1 ),
Filegroup [airavcache fg8]
(Name = 'airavcache fg8 ',
Filename =
'D: \ data \ fg8 \ airavcache fg8.ndf ',
Size = 5 MB,
Maxsize = 500,
Filegrowth = 1 ),
Filegroup [airavcache fg9]
(Name = 'airavcache fg9 ',
Filename =
'D: \ data \ fg9 \ airavcache fg9.ndf ',
Size = 5 MB,
Maxsize = 500,
Filegrowth = 1 ),
Filegroup [airavcache fg10]
(Name = 'airavcache fg10 ',
Filename =
'D: \ data \ fg10 \ airavcache fg10.ndf ',
Size = 5 MB,
Maxsize = 500,
Filegrowth = 1 ),
Filegroup [airavcache fg11]
(Name = 'airavcache fg11 ',
Filename =
'D: \ data \ fg11 \ airavcache fg11.ndf ',
Size = 5 MB,
Maxsize = 500,
Filegrowth = 1 ),
Filegroup [airavcache fg12]
(Name = 'airavcache fg12 ',
Filename =
'D: \ data \ fg12 \ airavcache fg12.ndf ',
Size = 5 MB,
Maxsize = 500,
Filegrowth = 1)
After creation
Open the FG1 folder and check that the airavcachefg1.ndf file is missing.
Create a partition function
CodeCopy codeThe Code is as follows: Use airavcache
Go
-- Create a function
Create Partition Function [airavcache partition range] (datetime)
As range left for values ('2017-09-01 ', '2017-10-01', '2017-11-01 ', '2017-12-01', '2017-01-01 ', '2017-02-01 ', '2017-03-01', '2017-04-01 ', '2017-05-01', '2017-06-01 ', '2017-07-01 ');
Create a partition Architecture
CodeCopy codeThe Code is as follows: Create Partition Scheme [airavcache Partition Scheme]
As partition [airavcache partition range]
To ([airavcache FG1], [airavcache FG2], [airavcache FG3], [airavcache fg4], [airavcache fg5], [airavcache fg6], [airavcache fg7], [airavcache fg8],
[Airavcache fg9], [airavcache fg10], [airavcache fg11], [airavcache fg12]);
Create a table using the airavcache partitiion scheme ArchitectureCopy codeThe Code is as follows: Create Table [DBO]. [avcache] (
[Citypair] [varchar] (6) Not null,
[Flightno] [varchar] (10) null,
[Flightdate] [datetime] not null,
[Cachetime] [datetime] not null default (getdate ()),
[Avnote] [varchar] (300) null
) On [airavcache Partition Scheme] (flightdate); -- note that the [airavcache Partition Scheme] architecture is used here, which is partitioned by flightdate
Query partition informationCopy codeThe Code is as follows: -- View usage
Select *, $ partition. [airavcache partition range] (flightdate)
From DBO. avcache
We can see that September and October were separated.