Sql Server Indexes - Rti.etf.bg.ac.rs

7m ago
9 Views
1 Downloads
1.49 MB
32 Pages
Last View : 22d ago
Last Download : 3m ago
Upload by : Melina Bettis
Transcription

MS Sql Server Indexes Author: Nemanja Kojic MScEE 1 of 32

Indexing Vital for system performance Improves query execution performance NOT one size fits all – trade offs must be made Penalties during INSERT/UPDATE – index update Two types of indexes: – Clustered Indexes – NonClustered Indexes 2 of 32

Index example 3 of 32

Non-Clustered Index Data in pages in random order Logical data order in index NonClustered index tree – Keys in sorted order – Leaf pages contain pointers to rows in data pages Typicaly created on column used in JOIN, WHERE, ORDER BY Good for tables whose values may be modified frequently 4 of 32

NonClustered Index (cont.) MS Sql Server: CREATE INDEX - nonClustered by default Allowed more than index on a db table MS Sql Server 2008: up to 999 nonClustered indexes per table 5 of 32

Non-Clustered Index example 6 of 32

Non-Clustered Index - summation Create index on columns which are: – Frequently used in search criteria – Used to JOIN different tables – Used as foreign key fields – Of having high selectability – Used in ORDER BY clause – Of type XML (primary and secondary indexes) 7 of 32

Clustered Index Re-orders data rows to match the index (rows in sort order on disk) Only one clustered index per table! Leaf level of the index tree - actual data rows Good for sequential access, and range selection 8 of 32

Clustered Index (cont.) MS Sql Server INSERTS data according to the way a clustered index was created Most often: PRIMARY KEY Clustered Index Every table SHOULD have clustered index w/o clustered index: records added to the end of the last page w/ clustered index: data added to suitable position dictated by the index 9 of 32

Clustered Index example 10 of 32

Clustered and Non-Clustered Index combined 11 of 32

Covering indexes Extending functionality of nonCls indexes Adding non-key columns to the leaf level Index covers more types of queries Covering Indexes Indexes w/ incl. columns Great performance benefits 12 of 32

Filtering indexes NonClustered index with a record filter Covers a subsed of records in a table Reduces storage space for index Better performance Decreased INSERT penalty 13 of 32

Index selectivity and Density Selectivity: number of distinct key values in the table PRIMARY KEY, UNIQUE – perfectly selective The higher selective Index, the better perform. Density: number of duplicate key values in the table Query optimizer: index seek, index scan 14 of 32

Fill factor Tuning storage and performance Fill factor % of space for data in leaf pages Remainder of the page for future growth E.g. Fill factor 80% 20% page empty Reserved space between index rows (rather than at the of the index) Applied on CREATE or REBUILD INDEX 15 of 32

Fill factor - guidelines Depends on how data are accessed Data inserted at the end of the table FILL FACTOR 90%-100% Data inserted anywhere FILL FACTOR 60%-80% The lower FF, the higher storage for the index In general: appropriate FF requires a lot of testing and probing 16 of 32

Creating indexes – Best Practices Keep indexes narrow (one or few columns) Clustered index on every table Clustered index on a highly selective column Clustered index on a column that is never upd. Default: clustered index on PRIMARY KEY col. Be aware of penalties during INSERT/UPDATE Eliminate duplicate indexes. Check the default FILL FACTOR Non-clustered indexes can be created in different file groups, which may increase performance 17 of 32

Order of fields on each index? Bad order index is not useful Most selective columns go first Sql Server knows data distribution only for the first column! Don’t place column from clustered index to a non-clustered index 18 of 32

EXAMPLES 19 of 32

Table with NO indexes select * 20 of 32

Table w/ non-clust. index on LastName select * 21 of 32

Table w/ clust. index on LastName select * 22 of 32

Table w/ non-clust. index on LastName selecting LastName 23 of 32

Table w/ clust. Index on LastName selecting LastName 24 of 32

Table w/ non-clust. Index on LastName selecting LastName and FirstName 25 of 32

Table w/ non-clust. Index on LastName including FirstName 26 of 32

Table with filtered index 27 of 32

Building indexes in Asc vs. Desc Order selecting all records 28 of 32

Building indexes in Asc vs. Desc Order select w/ ORDER BY ASC, no INDEX 29 of 32

Building indexes in Asc vs. Desc Order select w/ ORDER BY ASC, with INDEX 30 of 32

Building indexes in Asc vs. Desc Order select w/ ORDER BY DESC, no INDEX 31 of 32

Building indexes in Asc vs. Desc Order select w/ ORDER BY DESC, with INDEX 32 of 32

MS Sql Server INSERTS data according to the way a clustered index was created Most often: PRIMARY KEY Clustered Index Every table SHOULD have clustered index w/o clustered index: records added to the end of the last page w/ clustered index: data added to suitable position dictated by the index 9 of 32

Related Documents:

Morningstar is by far the most widely used website for ETF information. WEBSITES USED FOR ETF INFORMATION . Morningstar Seeking Alpha ETF.com Yahoo! Finance ETF Center ETF Database (etfdb.com)/ETF Trends S&P Capital IQ IBD ETF Center ETF Guide ETF Daily

Server 2005 , SQL Server 2008 , SQL Server 2008 R2 , SQL Server 2012 , SQL Server 2014 , SQL Server 2005 Express Edition , SQL Server 2008 Express SQL Server 2008 R2 Express , SQL Server 2012 Express , SQL Server 2014 Express .NET Framework 4.0, .NET Framework 2.0,

during and after the ETF Sum-up day will be invested to ETFs only at the ETF Execution day of the following month. ETF Sum-up day shall be the Monday before the ETF Execution day. If such day is a public holiday, the ETF Sum-up day shall move to the next possible business day. ETF Execution day - The day when positions for ETF portfolio are .

MS SQL Server: MS SQL Server 2017, MS SQL Server 2016, MS SQL Server 2014, MS SQL Server 2012, MS SQL Server 2008 R2, 2008, 2008 (64 bit), 2008 Express, MS SQL Server 2005, 2005 (64 bit), 2005 Express, MS SQL Server 2000, 2000 (64 bit), 7.0 and mixed formats. To install the software, follow the steps: 1. Double-click Stellar Repair for MS SQL.exe.

SQL Server 2005 SQL Server 2008 (New for V3.01) SQL Server 2008 R2 (New for V3.60) SQL Server 2012 (New for V3.80) SQL Server 2012 R2 (New for V3.95) SQL Server 2014 (New for V3.97) SQL Server 2016 (New for V3.98) SQL Server 2017 (New for V3.99) (Recommend Latest Service Pack) Note: SQL Server Express is supported for most situations. Contact .

4395 querying data with transact -sql (m20761) microsoft sql server 6552 querying microsoft sql server 2014 (m20461) microsoft sql server 1833 sql server performance tuning and optimization (m55144) microsoft sql server 4394 updating your skills to sql server 2016 (m10986) microsoft sql server

install the SQL Server Reporting Services 2019 or 2017 installation program. For more information, see Installing SQL Server Reporting Services for SQL Server 2019 and SQL Server 2017 To use the SQL Installer to install a full version of SQL Server software (for example, SQL Server 2019 Standard editio

4. To upgrade SQL Server 2008 SP3 Express to SQL Server 2012 SP2 Express, launch th e installer for SQL Server 2012 SP2 Express, and then follow the wizard. 5. Select the Upgrade from SQL Server 2005, SQL Server 2008 or SQL Server 2008R2 option under the Installation option. The Upgrade to SQL