Home > Articles > Data > SQL Server

  • Print
  • + Share This
Like this article? We recommend

Location of Query Processing

Control of the location of processing can be managed from the Large Level Threshold property setpoint. Although the large level value is a critical influencer of which location is selected for query processing, we can also control the location using other means—chief of which is the Execution Location parameter.

Execution Location Parameter

We have learned that large levels, as defined by the threshold, are processed solely at the server level, not sent to the client unless a specific request is made. Small levels, in contrast, are sent to the client to be processed, even if the associated level is not requested in its entirety. Before we undertake to control the location of processing, we should understand the benefits and costs associated with the client/server processing options from which we can select. Some of the more important of these are summarized in Table 1.

Table 1 Advantages and Disadvantages of Processing Location Options

Client versus Server Processing

Costs and Benefits

Processing Location

Disadvantages

Advantages

Server

Consumes more CPU and memory resources.

Takes longer to process.

Results can be cached on the server, so that requests for the same result sets by other client applications are quickly available.

Client

Potentially much greater network traffic because large amounts of data are being dispatched from the server.

Client-based processing means client-based caching. This results in a loss of rapid fulfillment of recurring requests by multiple clients for the same information.

Placing processing burden on the client relieves the server of virtually all resource requirements.


The Execution Location connection parameter provides another more direct means of controlling location of processing of our MDX queries. To build a query that will be executed on the server, we need only use the OLE DB property ExecutionLocation, which specifies where the query is to be resolved. The setpoint options for ExecutionLocation are displayed in Table 2.

Table 2

Setpoint

Meaning

0

Default. For compatibility with earlier versions, this means the same as Value 1. (Subject to change in future versions.)

1

The PivotTable Service selects the query processing location (server or client application) that it predicts will provide the best performance.

2

Queries are processed on the client application.

3

Queries are executed on the server. (Queries that contain session-scoped calculated members, user-defined sets, or user-defined functions are exceptions.)


The location of query processing can be forced to our choice of server or client by using the Execution Location property. The default setting, Automatic, allows the PivotTable Service to determine where the query should be processed, based upon its prediction of which option will mean better performance. When using the default option (where the processing location is determined internally), a critical factor in the determination of the execution location is the Large Level Threshold property we have already discussed. Suppose the level is set at 1,000. The PivotTable Service forces "large level" treatment if it determines that the query will require the aggregation of 1000 or more members in a given dimension level. If the query does not involve a large level, the evaluation of the query occurs at the client. If a large level is apparent, the query is evaluated at the server.

Other Means of Influencing Execution Location

At the individual query level, no way is readily available for a client application to direct execution location. We can, however, mandate that large level operations execute at the client through the use of an indirect means: The specification of a named set for use within the query will force processing at the client level. We can, therefore, create a named set (using either of the CREATE SET or WITH SET clauses) containing members of a large level, at the client; then use the same named set in a query to force client-based execution.

Other considerations with regard to control of the processing location include calculated members and calculated cells. The manner of creation of a calculated member is important for determining its location-fixing effects. Using the CREATE MEMBER or WITH MEMBER clauses with a query to define a calculated member at the server will produce a calculated member that can be processed at the server or client equally successfully. By contrast, using CREATE MEMBER to produce a calculated member within a session will result in forced client-based execution of the query that houses it. Cell calculations may also cause forced client-based processing. Again, the manner in which the cell calculations are defined is important for determining their location-fixing effects. A cell calculation that is created with the CREATE CELL CALCULATION clause at either the client or the server can be processed at the server. By contrast, the use of the WITH CELL CALCULATION clause at the client will result in a query whose processing will be client-based.

The existence of two conditions can force a query to process on the server: a reference to a filter operation within the query and (consistent with our discussion regarding large levels earlier) a large dimension level. Let's take a look at the mechanics behind this in a little more detail. We will first fire up the MDX sample application, having seen in past articles that it provides an excellent platform from which to learn about MDX and about the data and the metadata in our cube. Many of the MDX operations that might be performed from a client application can be simulated here or elsewhere, and we can thus often gain another perspective of the interplay of the OLAP data source and MDX through the sample application.

NOTE

Keep in mind that client applications differ in many ways; and individual setpoints, design characteristics, capabilities, and other considerations likely mean differences in operation and performance using the techniques we describe.

  1. Go to the Start button on the PC; navigate to Microsoft SQL Server, Analysis Services; then navigate to the MDX sample application.

    We are initially greeted by the Connect dialog box, as shown in Figure 4.

    Figure 4Figure 4 The Connect dialog box for the MDX sample application.

    Figure 4 depicts the name of my server, MOTHER, and properly indicates that we will be connecting via the MSOLAP provider (the default).

  2. Click OK.

    NOTE

    We might also choose to cancel the dialog box and connect later by clicking Connect on the File menu.

    The MDX sample application window appears.

  3. Clear the top area (the query pane) of any remnants of queries that might appear.

  4. Ensure that FoodMart 2000 is selected as the database name in the DB box of the toolbar.

  5. Select the Warehouse cube in the Cube drop-down list box.

The MDX sample application window should resemble that shown in Figure 5, complete with the information from the Warehouse cube displaying in the Metadata tree (the left section of the Metadata pane).

Figure 5Figure 5 The MDX sample application window (compressed view).

We will create an MDX query that helps us to "qualify" a query as coming within the two conditions that force a query to process on the server.

  1. Type the following query into the query pane of the sample application:

    -- Step 1-1: Qualification Through Count
    WITH
      MEMBER[Measures].[Count] AS 
      'COUNT({ [Product].[Product Name].Members})'
    SELECT
    {[Measures].[Count]}ON COLUMNs
    FROM Warehouse

    Our intent is to ascertain that an upcoming example expression will "qualify" as meeting conditions that would force it to process on the server. We are simply obtaining a count of the members of a given level.

  2. Execute the query using the Run Query button.

    The results set appears, as shown in Figure 6.

    Figure 6Figure 6 Results set, count query.

  3. Save the query as Step1-1.

We see that [Product].[Product Name].Members refers to a genuine large level because the number of members in the Product Name level (1,560) of the Product dimension exceeds the large level threshold we set earlier (750). For that matter, it exceeds even the default threshold that existed before our modifications (1000). (The number of members is also verifiable at the RDBMS level in the FoodMart2000.mdb sample that is installed with MSSQL Server 2000 Analysis Services.)

Let's use the level whose population we have just quantified in the COUNT query to illustrate. The inclusion of a filter within our query will also be a driver for server-based processing.

  1. Create the following new query:

    -- Step 1-2: Qualification Through Count & Filter
    SELECT
    {[Measures].[Units Shipped]} ON COLUMNS,
    TopCount ([Product].[Product Name].Members, 9
    7, [Measures].[Units Shipped]) ON ROWS
    FROM Warehouse

    The use of TopCount provides an instance in which server-based execution is likely to be appropriate for yet another reason: Most of the large level will be pruned away by the filter action before returning the result. The existence of a filter operation within the query is another driver for server processing.

  2. Execute the query using the Run Query button.

    The results set appears, as shown in Figure 7.

    Figure 7Figure 7 Results set, topcount query.

  3. Save the query as Step1-2.

Although level-size and filter requirements are good criteria to use in most cases for determining the likelihood of forced server-based processing, there are scenarios in which even meeting or exceeding the parameters of these two criteria will not force a query to execute on the server. Examples of these situations include the presence of a function or functions within the query (say a user-defined function that is registered solely on the client) that cannot execute on the server. Also, as is somewhat obvious, a query that is executed against a local cube will not process on a remote server.

The execution location can be set at the query level (and can thus be specified for individual queries) or at the connection level (as the default execution location for all queries run via the respective connection). A connection string example is as follows:

Execution Location=3;
  • + Share This
  • 🔖 Save To Your Account