Tải bản đầy đủ (.pdf) (10 trang)

Microsoft SQL Server 2008 R2 Unleashed- P211 pptx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (808.4 KB, 10 trang )

ptg
2064
CHAPTER 51 SQL Server 2008 Analysis Services
FIGURE 51.35 The Comp Sales cube definition in the cube designer.
Building and Deploying the Cube
You basically have a cube definition now, but it is just an empty shell. You need to process it
and then deploy it so that it is instantiated and populated with data (via the data source view).
Remember that this cube definition is a solution project, just like a C# code project. It must be
deployed before it can be used. First, you need to verify that the properties of the cube you are
building are set correctly. You must have these properties correct before the cube can be
processed. (Process, in this case, means build the cube structure and populate the measures and
their associated dimensions.) You can assume that the properties will not be set correctly, so
you should take a quick look and update them accordingly. You start by going to the Project
menu item in Visual Studio and locating the Properties item entry (see Figure 51.36).
After you select this option, you navigate to the Deployment entry (the configuration property
on the bottom). You need to focus on the Target (the target of the deployment) properties. As
you can see in Figure 51.37, the
Server property should be pointing to the location where you
want this cube to be deployed. The
Database property is simply the name under which you
will deploy the database. For this example, you should make sure to specify a valid Server
value; the default is
(localhost). The default in this property usually is not what you want to
happen and usually results in an error during the deployment step. Therefore, you should
specify this value explicitly (such as
DBARCH-LT2\SQL08DE01, which is the Analysis Services
server, and
CompSalesUnleashed as the Database entry). After the cube is deployed, you will be
able to connect to this server (SSAS engine) with SSMS and administer the cube accordingly.
After you apply these property changes, you are ready to first do a build and then deploy
your SSAS cube. You start by making sure you have a successful build by using the Build


menu item on the toolbar or using the specific build option for the current SSAS solution:
Build CompSalesUnleashed. They both do the same thing. If you have no errors (and you
have received a Build Succeeded message in the lower-left message bar of Visual Studio),
you can deploy this SSAS solution.
ptg
2065
An OLAP Requirements Example: CompSales International
51
FIGURE 51.36 Selecting the cube properties for Comp Sales from the Project menu.
FIGURE 51.37 Deployment properties for the Comp Sales cube.
Again, you should choose the Build menu item in the toolbar and click the Deploy
Solution option to deploy this cube. Immediately, a Deployment Progress dialog box
appears in the lower-right corner of Visual Studio. When the deployment has progressed,
you receive a Deployment Completed Successfully message.
Populating the Cube with Data
Now you can process actual data into your cube from the data source view. To do so, you
right-click the Comp Sales cube entry in the Solution Explorer and choose the Process
item or choose the Process icon for the cube in the cube designer (second icon from the
left in the cube designer). A Process Cube dialog appears, with the object list of available
ptg
2066
CHAPTER 51 SQL Server 2008 Analysis Services
cubes to process. You select the Comp Sales cube (by highlighting it) and then click the
Run button to start the processing of data (see Figure 51.38). You can also see in Figure
51.38 that the Process Option defaults to Process Full. Other options here vary depending
on what part of the cube needs to be reprocessed (such as when you have structure
changes, data refreshes, incremental data changes, so on).
A Process Progress dialog appears as the processing begins. Remember that this data is the
dimension member values and the measure data values and has not been aggregated up
through a complete cube representation (at all levels in the hierarchies). That will be done

shortly, via the Aggregation Design Wizard. You can actually use your cube right now, but
browsing would be challenging from a performance point of view.
Aggregating Data Within the Cube
The last step of creating your OLAP cube is running through the Aggregation Design
Wizard and determining how best to represent and aggregate the data for your users. This
is point at which you must determine the optimal aggregation levels and storage method
for these aggregations (MOLAP, HOLAP, or ROLAP) for the optimal performance of queries
against the cube.
You double-click the cube entry in the Solution Explorer (
Comp Sales.cube) to bring up
the cube designer for your newly created cube. Then you click the Partitions tab to see the
current partition for Comp Sales. Figure 51.39 shows the default storage mode is MOLAP
FIGURE 51.38 Process Cube dialog for Comp Sales.
ptg
2067
An OLAP Requirements Example: CompSales International
51
and that there is no Aggregation Design for this cube yet. Just to the lower right of this
tab is the Storage Settings option, which shows the different storage options possible for
your partition, as shown in Figure 51.40.
You need to indicate what type of storage mode and caching options you want for the
partition that will contain your aggregations (these storage modes are discussed earlier in
this chapter). You want to optimize performance and don’t need real-time refreshes of the
data. For these reasons, you specify the MOLAP (native SSAS storage) mode. Figure 51.40
FIGURE 51.39 The Partitions for the Comp Sales cube.
FIGURE 51.40 Specifying MOLAP storage mode for your cube in the Storage Settings dialog.
ptg
2068
CHAPTER 51 SQL Server 2008 Analysis Services
shows this MOLAP specification in the Storage Settings dialog. This dialog works as a sliding

scale. You just need to make sure the slider is positioned at the MOLAP storage option.
You also want to take advantage of the proactive caching capabilities that come with SSAS.
You can activate this feature by clicking the Options button of this dialog and then check-
ing the Enable Proactive Caching check box at the top of the Storage Options dialog that
appears (see Figure 51.41). In addition, you use the option Update the Cache When Data
Changes, as indicated in Figure 51.41 along with interval times for these refreshes.
A good rule of thumb is to refresh the cache interval based on response requirements and
the volatility of the data from the data source views and whether the changes will have a
dramatic effect on the BI query results.
Now you can run through the Aggregation Design Wizard to see whether you can opti-
mize your partition for querying. You simply go to the Aggregation Design tab for this
cube (from the cube designer) and choose the Design Aggregations option (click the first
icon in the Design Aggregations tab or right-click within the Aggregation Design tab and
choose Design Aggregations). This launches the Design Aggregation Wizard.
FIGURE 51.41 Enabling proactive caching for the cube.
ptg
2069
An OLAP Requirements Example: CompSales International
51
First up is the dialog that allows you to specify object counts of the total population of
facts and the number of values at each hierarchical level within each dimension. If you
know what the full extent of counts will be for your cube, you can manually supply these
count values in the Estimated Count column (see Figure 51.42). You typically do this
when you have been able to load only a partial amount of data or the data will grow quite
rapidly over time. If you are building a statically sized cube and have populated the data
already, you just click the Count button to tell the wizard to use the actual data as the
basis of the aggregation.
The next dialog optimizes the storage, based on the level of aggregation. You can specify a
maximum storage approach (you create optimized storage based on the amount of disk
space you can allocate to the cube), tell the wizard to simply optimize to achieve a certain

percentage of performance gain (for example, 50%, 80%), specify to start the aggregation
design process dynamically, and stop when you feel the cube is optimized enough, or do
no design aggregation at all. You really want to see the design aggregation process happen.
Remember that the higher the performance you want, the more storage it will require
(and the longer it will take to reprocess the aggregations). As you can see in Figure 51.43,
you should select the I Click Stop option and stop the design aggregation when the opti-
mization level starts to level off (somewhere between 75% to 88% optimization level). Any
further optimization would really just waste storage space.
FIGURE 51.42 Specifying cube object counts for aggregation in the Aggregation Design
Wizard.
ptg
2070
CHAPTER 51 SQL Server 2008 Analysis Services
When you are satisfied with the aggregation design, you simply click NEXT and name this
design (the sample is named
AggregationDesignPrimary, as you can see in Figure 51.44).
You then assign this design aggregation to the partition to use in the Partition tab.
If your company has sales transaction data for the past five years and 250 stores that sell
an average of 1,000 items per day, the fact table will have 456,500,000 rows. This is obvi-
ously a challenge in terms of disk space by itself, without aggregation tables to go along
with it. The control that SSAS provides here is important in balancing storage and retrieval
speed (that is, performance versus size). Aggregations are built to optimize rollup opera-
FIGURE 51.43 Setting the optimal storage and query performance level in the Aggregation
Design Wizard.
FIGURE 51.44 Resulting aggregation design to be assigned to the Comp Sales Factoid parti-
tion.
ptg
2071
An OLAP Requirements Example: CompSales International
51

tions so that higher levels of aggregation are easily derived from the existing aggregations
to satisfy broader queries. If a high degree of query optimization weren’t possible due to
limitations in storage space, SSAS might choose to build aggregates of monthly or quar-
terly data only. If a user queried the cube for yearly or multiyear data, those aggregations
would be created dynamically from the highest level of pre-aggregated data. With disk
storage becoming more and more inexpensive and servers becoming more powerful, the
tendency is to opt for meeting performance gains. A recommended approach is to specify
between an 80% and 90% performance gain here.
You are now ready to complete the Aggregation Design Wizard. The final step is to either
process this aggregation or save your results and process it later. You should choose to
process this aggregation now and then click Finish (see Figure 51.45). The Process Progress
dialog appears immediately, and you get to watch the full extent of the cube’s aggregation
partitions being built (that is, populated). Aggregation SQL queries are actually created
under the covers to populate all these aggregation levels (which are implementing your
design levels). It’s nice to have Microsoft dynamically create these complex queries for this
critical performance optimization step so you don’t have to worry about it yourself.
When this step completes, you have a fully optimized cube that is ready for data brows-
ing. Congratulations!
Browsing Data in the Cube
You’re ready to browse some cube data now. There are several ways to view data in a
multidimensional cube. OLE DB for OLAP and ADO MD expose interfaces to do this kind
FIGURE 51.45 Deploy and process the aggregation now to complete your cube.
ptg
2072
CHAPTER 51 SQL Server 2008 Analysis Services
of data browsing, and many leading vendors have used these interfaces to build front-end
analysis tools and ActiveX controls. These tools should prove useful for developers of user
interfaces in data warehousing and data mart projects. You can also easily browse a cube’s
data from either Visual Studio or SSMS or via any tool or facility that uses the multidimen-
sional extensions of SQL (that is, SQL with DMX and MDX extensions).

To browse your newly created cube from SSMS, you fire up SSMS and connect to the SSAS
server (Analysis Services server type) on which you deployed your cube. You should not
connect to the SQL Server Database Engine. These are two completely different servers.
When you are connected, you expand the
Databases tree on the left until you can see the
cube you created (Comp Sales, in this example).
NOTE
In Visual Studio, you can simply click the Browse tab when you are in the cube design-
er. All browse functionality uses the same plug-ins, whether you are in Visual Studio or
SSMS. In either Visual Studio or SSMS, you can browse the cube (the entire cube with
all dimensions) or just a dimension (using the dimension browser).
In SSMS, you just right-click the Comp Sales cube entry and choose the Browse option. As
you can see in Figure 51.46, a multipaned, drag-and-drop interface is your view into the
data in your cube.
FIGURE 51.46 Browsing data in your cube in the SMSS data browser.
ptg
2073
An OLAP Requirements Example: CompSales International
51
The middle pane lists all cube objects that you can drag into the data browsing pane (on
the right). The data browser uses the Pivot Table Service to access and display your cube’s
data. You can expand any of the cube hierarchy objects and see the actual member entries
that are in your cube for each level. This capability is helpful when you want to further
filter data in the browser (for example, focus on a particular SKU value or a particular
geography, such as United States or France).
The data browsing pane is easy to use. For example, say that you simply want to see all
product sales and product returns for SKUs across all geographies, for each year in the
cube. To do this, you expand the measures object until you see all the measures in the
Comp Sales cube. Then you drag Sales Units to the center of the lower portion of the data
browsing pane (into the Drop Totals or Detail Fields Here section in the lower right). You

do the same for the Sales Returns measure. Data values (totals) for these measures are
already displayed immediately. These are the total (aggregated) values for sales returns and
sales units across all products, all geographies, and all times. To see the product break-
down of these data measures, you drag the SKU object within the product dimension
object to the Drop Column Fields Here section (just above where the data measures were
dropped). You immediately see the data measure values being broken out by each product
SKU value. Now, you drag the Year Time object within the time dimension to the Drop
Row Fields Here section (just to the left of where the data measures were dropped). You
now see the data broken out by the years along the left side (rows) in the cube that
contains sales and return data for products, as shown in Figure 51.47.
FIGURE 51.47 Sales units and sales returns for all SKUs by years in the SMSS data browser.

×