Tuesday, March 20, 2012
Big Mistake? - Indexes with includes on partition tables
partitioned tables. The tables are modest-sized, fact tables used for
aggregation. Each week, we slide the partitions.
The slide process is normally very fast. However, after adding include
columns to the indexes, the command to split the range in the partition
functions resulted in what appears to be runaway processes that gobbled up
system resources and maxxed out the transaction log. In fact, even after
emptying the tables of data and dropping the indexes, this happened. It was
only after I deleted the index partition scheme that the problem went away.
So... is there a problem with creating indexes with include columns on
partitioned tables where the partitions will slide? Is there something
exponential that goes on?
Thanks
Thanks,
CGW
I can't think of why simply including columns would show down the split.
Can you please post the DDL, including partition schemes and functions?
Hope this helps.
Dan Guzman
SQL Server MVP
"CGW" <CGW@.discussions.microsoft.com> wrote in message
news:2CDF1207-375E-4ABD-9723-D69A9BE1B010@.microsoft.com...
>I recently tried adding include columns to two indexes, one on each of two
> partitioned tables. The tables are modest-sized, fact tables used for
> aggregation. Each week, we slide the partitions.
> The slide process is normally very fast. However, after adding include
> columns to the indexes, the command to split the range in the partition
> functions resulted in what appears to be runaway processes that gobbled up
> system resources and maxxed out the transaction log. In fact, even after
> emptying the tables of data and dropping the indexes, this happened. It
> was
> only after I deleted the index partition scheme that the problem went
> away.
> So... is there a problem with creating indexes with include columns on
> partitioned tables where the partitions will slide? Is there something
> exponential that goes on?
> Thanks
> --
> Thanks,
> CGW
|||That could ba a lot of work for both of us. Are you just mildly curious, or
do you think you could really puzzle it out?
Thanks,
CGW
"Dan Guzman" wrote:
> I can't think of why simply including columns would show down the split.
> Can you please post the DDL, including partition schemes and functions?
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "CGW" <CGW@.discussions.microsoft.com> wrote in message
> news:2CDF1207-375E-4ABD-9723-D69A9BE1B010@.microsoft.com...
>
|||> That could ba a lot of work for both of us. Are you just mildly curious,
> or
> do you think you could really puzzle it out?
I'm quite interested in this problem and would like to try to help you
figure out what's going on. However, I'll need DDL to do so since I can't
think of anything obvious based on the information given. The only causes I
can think of isn't related to included columns.
One gotcha I've seen is that splitting a partition function will change all
the related partition schemes. If you have multiple tables using the same
scheme, all corresponding partitions will be split. I've run into an issue
where a staging table (with same scheme) wasn't empty when the function was
split so a lot of data needed to be moved in the staging table partitions
even though no data needed to be moved into the newly created partition of
the main table.
Hope this helps.
Dan Guzman
SQL Server MVP
"CGW" <CGW@.discussions.microsoft.com> wrote in message
news:00984490-298D-43AD-B820-BAA95680012F@.microsoft.com...[vbcol=seagreen]
> That could ba a lot of work for both of us. Are you just mildly curious,
> or
> do you think you could really puzzle it out?
> --
> Thanks,
> CGW
>
> "Dan Guzman" wrote:
Big Mistake? - Indexes with includes on partition tables
partitioned tables. The tables are modest-sized, fact tables used for
aggregation. Each week, we slide the partitions.
The slide process is normally very fast. However, after adding include
columns to the indexes, the command to split the range in the partition
functions resulted in what appears to be runaway processes that gobbled up
system resources and maxxed out the transaction log. In fact, even after
emptying the tables of data and dropping the indexes, this happened. It was
only after I deleted the index partition scheme that the problem went away.
So... is there a problem with creating indexes with include columns on
partitioned tables where the partitions will slide? Is there something
exponential that goes on?
Thanks
--
Thanks,
CGWI can't think of why simply including columns would show down the split.
Can you please post the DDL, including partition schemes and functions?
--
Hope this helps.
Dan Guzman
SQL Server MVP
"CGW" <CGW@.discussions.microsoft.com> wrote in message
news:2CDF1207-375E-4ABD-9723-D69A9BE1B010@.microsoft.com...
>I recently tried adding include columns to two indexes, one on each of two
> partitioned tables. The tables are modest-sized, fact tables used for
> aggregation. Each week, we slide the partitions.
> The slide process is normally very fast. However, after adding include
> columns to the indexes, the command to split the range in the partition
> functions resulted in what appears to be runaway processes that gobbled up
> system resources and maxxed out the transaction log. In fact, even after
> emptying the tables of data and dropping the indexes, this happened. It
> was
> only after I deleted the index partition scheme that the problem went
> away.
> So... is there a problem with creating indexes with include columns on
> partitioned tables where the partitions will slide? Is there something
> exponential that goes on?
> Thanks
> --
> Thanks,
> CGW|||That could ba a lot of work for both of us. Are you just mildly curious, or
do you think you could really puzzle it out?
--
Thanks,
CGW
"Dan Guzman" wrote:
> I can't think of why simply including columns would show down the split.
> Can you please post the DDL, including partition schemes and functions?
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "CGW" <CGW@.discussions.microsoft.com> wrote in message
> news:2CDF1207-375E-4ABD-9723-D69A9BE1B010@.microsoft.com...
> >I recently tried adding include columns to two indexes, one on each of two
> > partitioned tables. The tables are modest-sized, fact tables used for
> > aggregation. Each week, we slide the partitions.
> >
> > The slide process is normally very fast. However, after adding include
> > columns to the indexes, the command to split the range in the partition
> > functions resulted in what appears to be runaway processes that gobbled up
> > system resources and maxxed out the transaction log. In fact, even after
> > emptying the tables of data and dropping the indexes, this happened. It
> > was
> > only after I deleted the index partition scheme that the problem went
> > away.
> >
> > So... is there a problem with creating indexes with include columns on
> > partitioned tables where the partitions will slide? Is there something
> > exponential that goes on?
> >
> > Thanks
> > --
> > Thanks,
> >
> > CGW
>|||> That could ba a lot of work for both of us. Are you just mildly curious,
> or
> do you think you could really puzzle it out?
I'm quite interested in this problem and would like to try to help you
figure out what's going on. However, I'll need DDL to do so since I can't
think of anything obvious based on the information given. The only causes I
can think of isn't related to included columns.
One gotcha I've seen is that splitting a partition function will change all
the related partition schemes. If you have multiple tables using the same
scheme, all corresponding partitions will be split. I've run into an issue
where a staging table (with same scheme) wasn't empty when the function was
split so a lot of data needed to be moved in the staging table partitions
even though no data needed to be moved into the newly created partition of
the main table.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"CGW" <CGW@.discussions.microsoft.com> wrote in message
news:00984490-298D-43AD-B820-BAA95680012F@.microsoft.com...
> That could ba a lot of work for both of us. Are you just mildly curious,
> or
> do you think you could really puzzle it out?
> --
> Thanks,
> CGW
>
> "Dan Guzman" wrote:
>> I can't think of why simply including columns would show down the split.
>> Can you please post the DDL, including partition schemes and functions?
>> --
>> Hope this helps.
>> Dan Guzman
>> SQL Server MVP
>> "CGW" <CGW@.discussions.microsoft.com> wrote in message
>> news:2CDF1207-375E-4ABD-9723-D69A9BE1B010@.microsoft.com...
>> >I recently tried adding include columns to two indexes, one on each of
>> >two
>> > partitioned tables. The tables are modest-sized, fact tables used for
>> > aggregation. Each week, we slide the partitions.
>> >
>> > The slide process is normally very fast. However, after adding include
>> > columns to the indexes, the command to split the range in the partition
>> > functions resulted in what appears to be runaway processes that gobbled
>> > up
>> > system resources and maxxed out the transaction log. In fact, even
>> > after
>> > emptying the tables of data and dropping the indexes, this happened. It
>> > was
>> > only after I deleted the index partition scheme that the problem went
>> > away.
>> >
>> > So... is there a problem with creating indexes with include columns on
>> > partitioned tables where the partitions will slide? Is there something
>> > exponential that goes on?
>> >
>> > Thanks
>> > --
>> > Thanks,
>> >
>> > CGWsql
Monday, March 19, 2012
Big Mistake? - Indexes with includes on partition tables
partitioned tables. The tables are modest-sized, fact tables used for
aggregation. Each week, we slide the partitions.
The slide process is normally very fast. However, after adding include
columns to the indexes, the command to split the range in the partition
functions resulted in what appears to be runaway processes that gobbled up
system resources and maxxed out the transaction log. In fact, even after
emptying the tables of data and dropping the indexes, this happened. It was
only after I deleted the index partition scheme that the problem went away.
So... is there a problem with creating indexes with include columns on
partitioned tables where the partitions will slide? Is there something
exponential that goes on?
Thanks
--
Thanks,
CGWI can't think of why simply including columns would show down the split.
Can you please post the DDL, including partition schemes and functions?
Hope this helps.
Dan Guzman
SQL Server MVP
"CGW" <CGW@.discussions.microsoft.com> wrote in message
news:2CDF1207-375E-4ABD-9723-D69A9BE1B010@.microsoft.com...
>I recently tried adding include columns to two indexes, one on each of two
> partitioned tables. The tables are modest-sized, fact tables used for
> aggregation. Each week, we slide the partitions.
> The slide process is normally very fast. However, after adding include
> columns to the indexes, the command to split the range in the partition
> functions resulted in what appears to be runaway processes that gobbled up
> system resources and maxxed out the transaction log. In fact, even after
> emptying the tables of data and dropping the indexes, this happened. It
> was
> only after I deleted the index partition scheme that the problem went
> away.
> So... is there a problem with creating indexes with include columns on
> partitioned tables where the partitions will slide? Is there something
> exponential that goes on?
> Thanks
> --
> Thanks,
> CGW|||That could ba a lot of work for both of us. Are you just mildly curious, or
do you think you could really puzzle it out?
--
Thanks,
CGW
"Dan Guzman" wrote:
> I can't think of why simply including columns would show down the split.
> Can you please post the DDL, including partition schemes and functions?
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "CGW" <CGW@.discussions.microsoft.com> wrote in message
> news:2CDF1207-375E-4ABD-9723-D69A9BE1B010@.microsoft.com...
>|||> That could ba a lot of work for both of us. Are you just mildly curious,
> or
> do you think you could really puzzle it out?
I'm quite interested in this problem and would like to try to help you
figure out what's going on. However, I'll need DDL to do so since I can't
think of anything obvious based on the information given. The only causes I
can think of isn't related to included columns.
One gotcha I've seen is that splitting a partition function will change all
the related partition schemes. If you have multiple tables using the same
scheme, all corresponding partitions will be split. I've run into an issue
where a staging table (with same scheme) wasn't empty when the function was
split so a lot of data needed to be moved in the staging table partitions
even though no data needed to be moved into the newly created partition of
the main table.
Hope this helps.
Dan Guzman
SQL Server MVP
"CGW" <CGW@.discussions.microsoft.com> wrote in message
news:00984490-298D-43AD-B820-BAA95680012F@.microsoft.com...[vbcol=seagreen]
> That could ba a lot of work for both of us. Are you just mildly curious,
> or
> do you think you could really puzzle it out?
> --
> Thanks,
> CGW
>
> "Dan Guzman" wrote:
>
Sunday, February 12, 2012
Best way to do a calculation
I'm kinda stuck on how to accomplish the following. Help appreciated.
I have a fact table like so:
TimeByDay ProjectID TaskID %Complete ActualHours Planned Hours
4/4/07 001 002 .25 5 8
4/5/07 001 002 .30 6 8
4/6/07 001 002 .40 8 8
4/7/07 001 002 .45 8 8
I want to add a calculated measure that is the product of %Complete and the total planned hours. In my example, the total planned hours for task 002 is 32 hours (sum of all days for a given taskID and ProjectID)
I was thinking of adding the total to the fact table - which would yield alot of repetitive data.
However, If it wont kill performance - I'd prefer to have a calculated expression that computes the total hours then performs my %Complete * TotalHours calculation.
your help is very much appreciated.
Hello again JohnBGood.
If you create a calculated measure, in the cube, like MyCalculatedMeasure = [Measure].[%Complete]*[Measure].[Planned Hours]
,a client like Excel2007 would take care of creating the totals for you with this calculated measure.
You can also create a named calculation on you fact table, in the data source view, with TSQL like [%Complete]*[Planned Hours] and aggregate that, because it is hours that are possible to aggregate by sum().
HTH
Thomas Ivarsson
|||A good way to test the impact this would have on SSAS performance is to first define the measure in a query:
Code Snippet
with member [Measures].[Estimated Hours]
as
[Measures].[Percent Complete] * [Measures].[Planned Hours]
select
[Measures].[Estimated Hours] on 0,
[Project].[Project Name].Members on 1
from [My Project Cube]
Try this with various restrictions, etc. to see how it holds up. If it behaves well, you can use the formula in a calculated member that will make this query available to all your users in their various applications.
If you run into performance problems, try using the [Measures].[Planned Hours] measure on Axis 0 (Columns) to see if the performance problem is still there. If it is, the calculation isn't the source of the performance issue.
A couple other things .... be sure to consider the format of the value you want to return to your users. You can lookup the syntax of the "WITH MEMBER" clause in Books Online and it will show you how to define formats here. Also, consider your NonEmpty Behavior. With the NonEmpty Behavior, you identify when to return an Empty value (and skip the calculation). In this scenario, you might want to skip the calculation when [Measures].[Planned Hours] is empty because a calculated value would be meaningless.
Good luck,
Bryan Smith
Friday, February 10, 2012
Best way to calculate Customer Age
Code Snippet
Code Snippet
What is the best way to calculate a customer's age?
I have a customer table which acts as both a dimension and a fact table and a corresponding Activity Fact that shows what kind of activity type a customer associated with.
How do I calculate the following?
1. Customer Current Age based on DOB?
This one has to be calculated on the fly based on today's date.
I am thinking about adding a link from DOB to the time dimension
so DOB is a dimension of the dimension dimCustomer.
Or it can be a dimension of the Fact dimCustomer.
2. Customer Age at the time of Enrollment ?
For this one, I created a new calculated column in the DimCustomer table to show AgeAsOfEnrollmentDate by using
Case ISNULL(DateOfBirth,'1900-01-01')
WHEN '1900-01-01' THEN NULL
ELSE DATEDIFF(Month,DateOfBirth,Enrolldate)/12
End AS AgeAsOfEnrollmentDate
3. Customer Membership Age?
How do I calculate How long has the customer been a member based on the EnrollDate?
So for this, I need something calculated on the fly like
DATEDIFF(Month,Enrolldate, Current Day)/12
Code Snippet
DimCustomer
CustomerID int
AccountNo int
DateOfBirth datetime (example--> 19700531)
EnrollDate datetime (example --> 20060731)
Fact_Activity
ActivityID int
ActivityNo int
ActivityDate datetime (example --> 20070201)
CustomerID int
ActivityTypeID
DimActivityType
ActivityTypeID
ActivityType
ActivityTypeDescription
DimTime (is a role-playing dimension for EnrollDate and ActivityDate)
I am thinking about adding also for DateOfBirth.
This has a hierarchy CALENDAR
Calendar Year
Calendar Quarter
Month Of Year
FullDateKey
Hello Binh,
One way you could calculate the customer's age on the fly based on DOB is to create a new named calculation in the data source view of your cube, inside the customer table (similarly to what you did for point 2). In the expression field, you would need to use a T-SQL expression that returns the age of the customer with the desired accuracy. For instance, something like "datediff(year, [DateOfBirth], getdate())" or “datediff(month, [DateOfBirth], getdate())/12.
Hope this helps,
Artur
|||Hi Artur,
Yes, I know I can do this for both the Customer Current Age and the Enrollment Age,
but the problem is that these values need to be dynamic and if I put it in the data source view like you suggested,
I would have to reprocess the cube everyday for the age to reflect right?
If I somehow can calculate it in the calculation script, I don't have to reprocess the cube to see the new number right?