Sie sind auf Seite 1von 12

CREATING AND SWITCHING PARTITIONED TABLES AND INDEXES

Portal GuilleSQL
http://www.GuilleSQL.es

Guillermo Roldn (Madrid Spain) SQL Server Senior Consultant

Agenda

About Us Intro: Some partitioning benefits Lab Description


Objects Partitions Data Objective

Demo Conclusion Questions, Discussion & Links

About Us

OnLine and spanish User Group (Spain and Latam) Microsoft IT focused: SQL Server, SharePoint, Virtualization, etc. Articles, News, Videos/WebCasts 225+ registered members

Intro: Some partitioning benefits

Faster data loading and archiving, using partitioned tables. Properly filtered queries will access only the correct partitions. You can enable partition lock scalation on a per table basis. You can mark partitioned tables filegroups as read-only. You can compress individual partitions. You can rebuild only one index partition.

Lab Description - Objects

Table: tblDatos
Partion

Function: pfDatos Partition Scheme: psDatos

Table: tblDatosHistoricos
Partition

Function: pfDatosHistoricos Partition Scheme: pfDatosHistoricos

Lab Description - Initial Partitions

Lab Description - Initial Partitions

Lab Description - Initial Data


ID GUID DESCRIPCION Junio 2010 Mayo 2010 Abril 2010 Marzo 2010 Febrero 2010 Enero 2010 DESCRIPCION Diciembre 2009 Noviembre 2009 Octubre 2009 Septiembre 2009 FECHA 20100601 20100501 20100401 20100301 20100201 20100101 FECHA 20091201 20091101 20091001 20090901 $PARTITION 7 6 5 4 3 2 $PARTITION 1 1 1 1

tblDatos tblDatosHistorios

GUID GUID GUID GUID GUID ID GUID GUID GUID GUID

GUID
GUID

Agosto 2009
Julio 2009

20090801
20090701

1
1

Lab Description - Objective


ID GUID DESCRIPCION Julio 2010 Junio 2010 Mayo 2010 Abril 2010 Marzo 2010 Febrero 2010 DESCRIPCION Enero 2010 Diciembre 2009 Noviembre 2009 Octubre 2009 FECHA 20100701 20100601 20100501 20100401 20100301 20100201 FECHA 20100101 20091201 20091101 20091001 $PARTITION 7 6 5 4 3 2 $PARTITION 1 1 1 1

tblDatos tblDatosHistorios

GUID GUID GUID GUID GUID ID GUID GUID GUID GUID

GUID
GUID GUID

Septiembre 2009
Agosto 2009 Julio 2009

20090901
20090801 20090701

1
1 1

Demo

Conclusion

Check the requirements to using ALTER TABLE SWITCH PARTITION SWITCH requires source and target partitions existing on the same FileGroup (metadata operation) SPLIT empty partition for best performance (avoid scan partitions and data movement) MERGE empty partitions for best performance (avoid scan partitions and data movement) SWITCH is immediate, it is simply a metadata operation (like SPLIT and MERGE on empty partitions) SWITCH, SPLIT, MERGE: schema modification lock Up to 1000 partitions per table (Note: SQL Server 2008 SP2 enable up to 15000 partitions per table)

Questions, Discussion & Links


Portal GuilleSQL
http://www.guillesql.es

Particionamiento de tablas e ndices en SQL Server


http://www.guillesql.es/Articulos/Particionamiento_tablas_indices_SQLServer_Partitioning.aspx

Cmo cargar Tablas Particionadas con SELECT INTO en SQL Server: ALTER TABLE SWITCH PARTITION
http://www.guillesql.es/Articulos/SELECT_INTO_INSERT_INTO_Particionamiento_ALTER_TABL E_SWITCH_PARTITION.aspx

White Paper: Partitioned Table and Index Strategies Using SQL Server 2008
http://msdn.microsoft.com/en-us/library/dd578580.aspx

BOL - Partitioned Table and Index Concepts


http://msdn.microsoft.com/en-us/library/ms190787.aspx

Das könnte Ihnen auch gefallen