Chris's profileChris Webb's BI BlogBlogLists Tools Help
    5/27/2009

    BeginRange and EndRange connection string properties

    Using the Timeout connection string property is a good way of making sure that your queries don’t run for too long, but sometimes – for example when you’re using SSRS – you want to restrict the amount of data that a query returns. You can’t properly do this with Analysis Services, but it is almost possible…

    Consider the following query on Adventure Works:

    SELECT
    {[Measures].[Internet Sales Amount],[Measures].[Internet Tax Amount]}
    ON 0,
    [Date].[Date].[Date].MEMBERS
    ON 1
    FROM [Adventure Works]

    It returns 1189 rows and 3 columns. If you click on any of the cells containing data in SQL Management Studio, to see the cell properties, you’ll see that the CellOrdinal property contains the index of each cell in the cellset. So the top left hand cell is ordinal 0, the one to its right is 1, and so on until the last column where it starts again one row down:

    image

    Using the BeginRange and EndRange connection string properties, you can limit the cells in a cellset that actually get populated with data. Note that you can’t restrict the overall number of cells though, which would be more useful. Both these properties take an integer value which represents a cell ordinal: BeginRange is the first cell ordinal you want to contain data, EndRange is the last cell ordinal. Their default value is –1, which for BeginRange means start at the first cell ordinal and for EndRange means end at the last cell ordinal. So, for example, with BeginRange=4 and EndRange=7, running the query above would give the following output:

    image

    As I said, the overall number of cells in the cellset remains the same, but only the cells in the range we specified actually contain data. This ‘filtering’ happens after the query axes have been resolved, as far as I can see, so adding NON EMPTY on Rows for example does not filter out any of the empty rows. If you were using SSRS, however, you could do this filtering at the DataSet level.

    If you look in Profiler you’ll see that these properties have an affect on the amount of work SSAS does at query time. On a cold cache, with no BeginRange and EndRange set, the query scans all of the year partitions in the Internet Sales measure group as you would expect. But with BeginRange and EndRange set as above, on a cold cache SSAS only reads data from the 2001 partition.

    BTW, remember that if you’re experimenting with these connection string properties in SQLMS, when you’re finished you’ll need to either close and reopen SQLMS or set BeginRange=-1 and EndRange=-1 as a result of this bug (which still doesn’t seem to be fixed in SP1).

    Comments (7)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Chris Webbwrote:
    They're connection string properties - you need to add them to the connection string that is used whenever you connect to Analysis Services. How you do that will depend on the client tool you're using - which one are you using?
    July 9
    where can you set BeginRange and EndRange in connection string properties.
    Please show me step how to set range.
    Thanks
    July 9
    Hi,
    I want to restrict the Cube 2005 to show limited number of rows even User select more than 1000 record.
    How can i do it.Please help me in it.
    July 9
    Chris Webbwrote:
    Andrew, yes I would agree completely.
    June 1
    Andrew Wileswrote:
    Would you agree this is mostly commonly a design time problem generated part way through query design and before the full scope of the query is understood?

    In Intelligencia we automatically Subset the axes of queries in design time to limit the amount of data returned. This improves query building performance without affecting the final result. The user can "page" through the data if they need to see parts of the query that are not returned by default.
    June 1
    Chris Webbwrote:
    No, I don't think so unfortunately. For what you're describing, timeouts or some kind of basic query governor (see http://cwebbbi.spaces.live.com/blog/cns!7B84B0F2C239489A!3874.entry) would be a better option.
    May 29
    In my case users connect to the cube with Excel (2003/2007). Is there a way to force these connection string properties to be used for all connections (i.e. without relying on users manually entering it in Excel)? My intention here is to encourage (i.e. force) the use of cubes for high-level analysis and prevent users from designing queries that result in 1000s of cells being returned, which results in support problems (server overloaded, Excel hanging etc).
    May 28

    Trackbacks

    The trackback URL for this entry is:
    http://cwebbbi.spaces.live.com/blog/cns!7B84B0F2C239489A!4543.trak
    Weblogs that reference this entry
    • None