dbTalk Databases Forums  

fastest way to create partitions

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss fastest way to create partitions in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Steffi
 
Posts: n/a

Default fastest way to create partitions - 09-22-2004 , 06:29 AM






hi,
I have a cube and wanna create partitions by time dimension ( by year+
month)
Have any ideas to fastly create these partitions ?

TIA.




Reply With Quote
  #2  
Old   
Ramunas Balukonis
 
Posts: n/a

Default Re: fastest way to create partitions - 09-22-2004 , 09:15 AM






Simple use dso - copying one partition from another.

See in vbs below, i copied from my dts. Steps to implement:

1. connect to server, db and cube
2. get the template partition, from wich you'll make a copy
3. set the slice and the source table filter

Ramunas Balukonis


Function Main()

Const DSO_ServerStates_stateConnected = 1
Const DSO_SubClassTypes_sbclsRegular = 0
'Const DSO_CloneOptions_cloneObjectProperties = 0
Const DSO_CloneOptions_cloneMinorChildren = 1
Const DSO_OlapStorageModes_olapmodeMolapIndex = 0
Const maxpercent = 100

Const TemplatePartitionName = "Sales_Stock"
Const DateDimensionName = "Date.Date"

Dim DSOServer
Dim DSODatabase
Dim DSOCube
Dim DSOPartition
Dim DSODimension
Dim DSOLevel
Dim DSOAgg

Dim strServerName
Dim strDBName
Dim strCubeName
Dim strLastPartitionName

Set DSOServer = CreateObject ("DSO.Server")
Set DSODatabase = CreateObject ("DSO.Database")
Set DSOCube = CreateObject ("DSO.Cube")
Set DSOPartition = CreateObject ("DSO.Partition")
Set DSOTemplatePartition = CreateObject ("DSO.Partition")

strLastPartitionName = DTSGlobalVariables("TableName")
strServerName = DTSGlobalVariables("ServAddress")
strDBName = DTSGlobalVariables("DBName")
strCubeName = DTSGlobalVariables("CubeName")

DSOServer.Connect strServerName

If DSOServer.State <> DSO_ServerStates_stateConnected Then
Main = DTSTaskExecResult_Failure
Exit Function
End if

If Not DSOServer.MDStores.Find (strDBName) Then
Main = DTSTaskExecResult_Failure
Exit Function
End if
Set DSODatabase = DSOServer.MDStores.Item (strDBName)

If Not DSODatabase.Cubes.Find (strCubeName) Then
Main = DTSTaskExecResult_Failure
Exit Function
End if
Set DSOCube = DSODatabase.Cubes.Item(strCubeName)

If DSOCube Is Nothing Then
Main = DTSTaskExecResult_Failure
Exit Function
End If

If Not DSOCube.partitions.Find (strLastPartitionName) Then
Set DSOPartition = DSOCube.MDStores.AddNew (strLastPartitionName, 0)
If Not DSOCube.MDStores.Find(strLastPartitionName) Then
Main = DTSTaskExecResult_Failure
Exit Function
End If

Set DSOTemplatePartition = DSOCube.MDStores.Item(TemplatePartitionName)
DSOTemplatePartition.Clone DSOCube.MDStores.Item(strLastPartitionName),
DSO_CloneOptions_cloneMinorChildren

'Set DSOPartition = DSOCube.MDStores.Item(strLastPartitionName)


DSOPartition.AggregationPrefix = strLastPartitionName & "_"



If Not DSOPartition.Dimensions.Find(DateDimensionName) Then
Main = DTSTaskExecResult_Failure
Exit Function
End if

Set DSODimension = DSOPartition.Dimensions.Item(DateDimensionName)

Set DSOLevel = DSODimension.Levels.Item("(All)")
DSOLevel.SliceValue = "All dates"
Set DSOLevel = DSODimension.Levels.Item(1)
DSOLevel.SliceValue = CLng( Left(Right(strLastPartitionName, 6), 4) )
Set DSOLevel = DSODimension.Levels.Item(2)
DSOLevel.SliceValue = CLng(Right(strLastPartitionName, 2))

dimkey = CLng(Right(strLastPartitionName, 6)) - 200000

DSOPartition.SourceTableFilter = """dbo"".""Sales_Stock"".""slst_date_id""
Quote:
= " & dimkey & "01 and ""dbo"".""Sales_Stock"".""slst_date_id"" <= " &
dimkey & "31"

DSOPartition.Update

End if



DSOServer.CloseServer
Set DSOServer = Nothing
Set DSODatabase = Nothing
Set DSOCube = Nothing
Set DSOPartition = Nothing

Main = DTSTaskExecResult_Success
End Function



"Steffi" <steffibev (AT) hotmail (DOT) com> wrote

Quote:
hi,
I have a cube and wanna create partitions by time dimension ( by year+
month)
Have any ideas to fastly create these partitions ?

TIA.






Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.