Partitioning is the process of breaking or separating something into smaller pieces
Partitioning a HDD allows for smaller, separate instances
Breaking data in a table down into smaller groupings allow for faster processing
Each partition created, if there is an index, will have a separate B-Tree
2.Steps in Creating a Partition
Create a Partition Function
Create File Groups & Assign a File to Each
Create a Partition Scheme
Create/Modify a Table/Index with Partition Scheme
3.Partition Point to Consider
Partitioning can create extra index B-Tree’s to monitor. Be sure the table should have an index at all
Partitioning can be done on tables easily, undoing them requires dropping the table
Partitioning takes time and memory, don’t partition unless it’s necessary
Usually only performed in Data Warehouses
can have 15000 partitions
always use data to create partition
4. 优势
when index is created on partitioned table,A b-tree is created for each partition index depth is less
rebuild / reorganize index, only on particular partition faster and easy
if some wrong happened on a particular partition, it will not interval other partition
we can place partitions on different file groups easy back up data reterival fast
truncate partition faster than delete SWITCH (move data to other place?) fast
minize lock; max lock is on partition
5. disadvantage
when we have more partition,we need merge them; maintaince and overhead
6.note
you can create file groups and add partitions to different file groups but it is not a mandatory step.
ndf :secondary files
mdf: primary file
every table has partition(?)
Common Questions on Partitioning
How do you create partitioning on an existing table without dropping it https://www.mssqltips.com/sqlservertip/5296/implementation-of-sliding-window-partitioning-in-sql-server-to-purge-data/
How do you create partitioning on an existing table with CI without dropping table
How do you create different types of indexes on different partitions filtered index(?)
What is sliding window or rolling window mechanism in partitions https://www.databasejournal.com/features/mssql/partitioning-in-sql-server-managing-sliding-window-scenario.html
How can you back up data faster with partitions
What is the new feature of 2016 related to partitioning? --TRUNCATE TABLE
WITH PARTITION (1)
How many partitions are possible for each table? --2012 AND LATER 15000
create partition function part_func (int)
as
range left for values (50,100,150,200)
alter database test_db
add filegroup filegroup1
alter database test_db
add filegroup filegroup2
alter database test_db
add filegroup filegroup3
alter database test_db
add filegroup filegroup4
alter database test_db
add filegroup filegroup5
alter database test_db
add file
(name=fg1_dat,
filename="c:\partition\fg1.ndf",
size = 30mb,
maxsize =50mb,
filegrowth = 5mb)
to filegroup filegroup1
alter database test_db
add file
(name=fg2_dat,
filename="c:\partition\fg2.ndf",
size = 30mb,
maxsize =50mb,
filegrowth = 5mb)
to filegroup filegroup2
alter database test_db
add file
(name=fg3_dat,
filename="c:\partition\fg3.ndf",
size = 30mb,
maxsize =50mb,
filegrowth = 5mb)
to filegroup filegroup3
alter database test_db
add file
(name=fg4_dat,
filename="c:\partition\fg4.ndf",
size = 30mb,
maxsize =50mb,
filegrowth = 5mb)
to filegroup filegroup4
alter database test_db
add file
(name=fg5_dat,
filename="c:\partition\fg5.ndf",
size = 30mb,
maxsize =50mb,
filegrowth = 5mb)
to filegroup filegroup5
create partition scheme part_scheme
as
partition part_func to
(filegroup1,filegroup2,filegroup3,filegroup4,filegroup5)
create table partition_table
(id int identity(1,1),name varchar(50)) on part_scheme (id)
drop table partition_table
drop partition scheme part_scheme
drop partition function part_func
alter database test_db
remove file fg1_dat
alter database test_db
remove file fg2_dat
alter database test_db
remove file fg3_dat
alter database test_db
remove file fg4_dat
alter database test_db
remove file fg5_dat
alter database test_db
remove filegroup filegroup1
alter database test_db
remove filegroup filegroup2
alter database test_db
remove filegroup filegroup3
alter database test_db
remove filegroup filegroup4
alter database test_db
remove filegroup filegroup5
note代码
USE CSI
GO
--Step 1: Create Partition Function
CREATE PARTITION FUNCTION fnPartFunction(DATE)
AS
RANGE LEFT FOR VALUES ('12/31/2016', '12/31/2017', '12/31/2018')
/*
Above Function will create 4 partitions
With LEFT orientation/align
P1 - Data with Dates on or Before 12/31/2016
P2 - 01/01/2017 - 12/31/2017
P3 - 01/01/2018 - 12/31/2018
P4 - Data with Dates on or After 01/01/2019
With RIGHT orientation/align
P1 - Data with Dates Before 12/31/2016
P2 - 12/31/2016 - 12/30/2017
P3 - 12/31/2017 - 12/30/2018
P4 - Data with Dates on or After 12/31/2018
*/
--You can create file groups and add partitions to different file groups but it is not a mandatory step.
You can assign all partitions to 1 file group or PRIMARY file group
ALTER DATABASE CSI
ADD FILEGROUP FG1
GO
ALTER DATABASE CSI
ADD FILEGROUP FG2
GO
ALTER DATABASE CSI
ADD FILEGROUP FG3
GO
ALTER DATABASE CSI
ADD FILEGROUP FG4
GO
--Creating secondary files for the Database
ALTER DATABASE CSI
ADD FILE
(NAME = FG1_Dat,
FileName = "C:\Partitions\FG1.ndf",
SIZE = 10 MB,
MaxSize = 50 MB,
FileGrowth = 5 MB)
TO FileGroup FG1
GO
ALTER DATABASE CSI
ADD FILE
(NAME = FG2_Dat,
FileName = "C:\Partitions\FG2.ndf",
SIZE = 10 MB,
MaxSize = 50 MB,
FileGrowth = 5 MB)
TO FileGroup FG2
GO
ALTER DATABASE CSI
ADD FILE
(NAME = FG3_Dat,
FileName = "C:\Partitions\FG3.ndf",
SIZE = 10 MB,
MaxSize = 50 MB,
FileGrowth = 5 MB)
TO FileGroup FG3
GO
ALTER DATABASE CSI
ADD FILE
(NAME = FG4_Dat,
FileName = "C:\Partitions\FG4.ndf",
SIZE = 10 MB,
MaxSize = 50 MB,
FileGrowth = 5 MB)
TO FileGroup FG4
GO
--Creating partition scheme based on the function created earlier
CREATE PARTITION SCHEME schPartScheme
AS
PARTITION fnPartFunction TO
(FG1, FG2, FG3, FG4) --Assigning each partition to a different file
GO
--In the following case we are assigning 3 partitions to 1 file and 4th to another file
CREATE PARTITION SCHEME schPartScheme
AS
PARTITION fnPartFunction TO
(FG1, FG1, FG1, FG4)
GO
--In the following case we are assigning all partitions to primary file (.mdf)
CREATE PARTITION SCHEME schPartScheme
AS
PARTITION fnPartFunction ALL TO
([PRIMARY])
GO
DROP TABLE IF EXISTS [tblPartition]
GO
--Creating table on partitions scheme
CREATE TABLE [dbo].[tblPartition](
[SalesPersonID] [int] NULL,
[OrderDate] [date] NULL,
[SalesOrderNumber] [nvarchar](25) NOT NULL,
[CustomerID] [int] NOT NULL,
[SubTotal] [money] NOT NULL,
[TaxAmt] [money] NOT NULL,
[Freight] [money] NOT NULL,
[TotalDue] [money] NOT NULL,
[FirstName] [nvarchar](50) NULL,
[LastName] [nvarchar](50) NULL
) ON schPartScheme (OrderDate)
GO
DECLARE @Days INT
SELECT @Days = DATEDIFF(DD, MAX(OrderDate), GETDATE())
FROM AdventureWorks2017.Sales.SalesOrderHeader H
INSERT INTO [tblPartition]
SELECT H.SalesPersonID, CAST(DATEADD(DD, @Days, H.OrderDate) AS DATE) OrderDate,
H.SalesOrderNumber, H.CustomerID, H.SubTotal, H.TaxAmt, H.Freight, H.TotalDue, P.FirstName, P.LastName
FROM AdventureWorks2017.Sales.SalesOrderHeader H
LEFT JOIN AdventureWorks2017.Person.Person P
ON P.BusinessEntityID = H.SalesPersonID
GO
--Creating index on partition scheme
CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
ON
刚在一台IBM Xserver服务器上装了RedHat Linux Enterprise AS 4,为了提高网络的可靠性配置双网卡绑定。
一、环境描述
我的RedHat Linux Enterprise AS 4安装双口的Intel千兆网卡,通过ifconfig -a命令看到eth0和eth1两张网卡。
二、双网卡绑定步骤:
2.1 修改/etc/sysconfig/network
1.AdviceMethods.java
package com.bijian.study.spring.aop.schema;
public class AdviceMethods {
public void preGreeting() {
System.out.println("--how are you!--");
}
}
2.beans.x
包括Spark Streaming在内的实时计算数据可靠性指的是三种级别:
1. At most once,数据最多只能接受一次,有可能接收不到
2. At least once, 数据至少接受一次,有可能重复接收
3. Exactly once 数据保证被处理并且只被处理一次,
具体的多读几遍http://spark.apache.org/docs/lates
具体思路参见:http://zhedahht.blog.163.com/blog/static/25411174200712895228171/
import java.util.ArrayList;
import java.util.List;
public class MinStack {
//maybe we can use origin array rathe
日期转换函数的详细使用说明
DATE_FORMAT(date,format) Formats the date value according to the format string. The following specifiers may be used in the format string. The&n