Monday, March 19, 2012
means of tracing query plans
aside from maybe using profiler, is there another means of displaying the qu
ery plans of procs being executed on the server over a period of time. ie. i
f a proc is being recompiled during execution is there a way for me to see t
he query plan of that proc
for each execution?
thanks.>> another means of displaying the query plans of procs being executed on
the server over a period of time
You might have third party software solutions. But I am not sure of anything
except profiler and the query analyzer window to display the execution plan
details. Moreover the profiler is the best way to go about such auditing
purposes. And why do you want to use other methods ?
HTH,
Vinod Kumar
MCSE, DBA, MCAD, MCSD
http://www.extremeexperts.com
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp
"simax" <anonymous@.discussions.microsoft.com> wrote in message
news:661F00F1-EFA3-42F1-B271-9D4A757417CB@.microsoft.com...
> Hi,
> aside from maybe using profiler, is there another means of displaying the
query plans of procs being executed on the server over a period of time. ie.
if a proc is being recompiled during execution is there a way for me to see
the query plan of that proc for each execution?
> thanks.|||Profiler is the only way.... And if you are looking for recompiles, of
course you do not have to capture the execution plans, just the
recompiles... SP3 introduced a new counter in Profiler which is included
with recompiles to explain why the recompile occurred... ( it is doc'd in
the service pack documentation.)
"simax" <anonymous@.discussions.microsoft.com> wrote in message
news:661F00F1-EFA3-42F1-B271-9D4A757417CB@.microsoft.com...
> Hi,
> aside from maybe using profiler, is there another means of displaying the
query plans of procs being executed on the server over a period of time. ie.
if a proc is being recompiled during execution is there a way for me to see
the query plan of that proc for each execution?
> thanks.
means of tracing query plans
aside from maybe using profiler, is there another means of displaying the query plans of procs being executed on the server over a period of time. ie. if a proc is being recompiled during execution is there a way for me to see the query plan of that proc for each execution
thanks.>> another means of displaying the query plans of procs being executed on
the server over a period of time
You might have third party software solutions. But I am not sure of anything
except profiler and the query analyzer window to display the execution plan
details. Moreover the profiler is the best way to go about such auditing
purposes. And why do you want to use other methods ?
--
HTH,
Vinod Kumar
MCSE, DBA, MCAD, MCSD
http://www.extremeexperts.com
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
"simax" <anonymous@.discussions.microsoft.com> wrote in message
news:661F00F1-EFA3-42F1-B271-9D4A757417CB@.microsoft.com...
> Hi,
> aside from maybe using profiler, is there another means of displaying the
query plans of procs being executed on the server over a period of time. ie.
if a proc is being recompiled during execution is there a way for me to see
the query plan of that proc for each execution?
> thanks.|||Profiler is the only way.... And if you are looking for recompiles, of
course you do not have to capture the execution plans, just the
recompiles... SP3 introduced a new counter in Profiler which is included
with recompiles to explain why the recompile occurred... ( it is doc'd in
the service pack documentation.)
"simax" <anonymous@.discussions.microsoft.com> wrote in message
news:661F00F1-EFA3-42F1-B271-9D4A757417CB@.microsoft.com...
> Hi,
> aside from maybe using profiler, is there another means of displaying the
query plans of procs being executed on the server over a period of time. ie.
if a proc is being recompiled during execution is there a way for me to see
the query plan of that proc for each execution?
> thanks.
means of tracing query plans
aside from maybe using profiler, is there another means of displaying the query plans of procs being executed on the server over a period of time. ie. if a proc is being recompiled during execution is there a way for me to see the query plan of that proc
for each execution?
thanks.
>> another means of displaying the query plans of procs being executed on
the server over a period of time
You might have third party software solutions. But I am not sure of anything
except profiler and the query analyzer window to display the execution plan
details. Moreover the profiler is the best way to go about such auditing
purposes. And why do you want to use other methods ?
HTH,
Vinod Kumar
MCSE, DBA, MCAD, MCSD
http://www.extremeexperts.com
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
"simax" <anonymous@.discussions.microsoft.com> wrote in message
news:661F00F1-EFA3-42F1-B271-9D4A757417CB@.microsoft.com...
> Hi,
> aside from maybe using profiler, is there another means of displaying the
query plans of procs being executed on the server over a period of time. ie.
if a proc is being recompiled during execution is there a way for me to see
the query plan of that proc for each execution?
> thanks.
|||Profiler is the only way.... And if you are looking for recompiles, of
course you do not have to capture the execution plans, just the
recompiles... SP3 introduced a new counter in Profiler which is included
with recompiles to explain why the recompile occurred... ( it is doc'd in
the service pack documentation.)
"simax" <anonymous@.discussions.microsoft.com> wrote in message
news:661F00F1-EFA3-42F1-B271-9D4A757417CB@.microsoft.com...
> Hi,
> aside from maybe using profiler, is there another means of displaying the
query plans of procs being executed on the server over a period of time. ie.
if a proc is being recompiled during execution is there a way for me to see
the query plan of that proc for each execution?
> thanks.
Friday, March 9, 2012
MDX Question on getting the top record for each....
I have scenario where a Item/Store combination can appear multiple times for the same period and to get the most recent record within a range ([Dim ZeroSalesDays].[Zero Sales Days]), I need to return the most current record. So I created measure with aggregation usage as last non empty.
So the below query works fine in that scenario.
SELECT
{
[Measures].[Tagged], [Measures].[Void],[Measures].[On Shelf],(Aggregation usage – sum)
[Measures].[Last Tagged],[Measures].[Last Void](Aggregation usage – Last Non Empty)
} ON COLUMNS,
NONEMPTYCROSSJOIN
(
{[Dim Product].[Item Id].Children},
{[Dim Store].[StoreName].Children}
)
ON ROWS
FROM sifdw
WHERE
(
{[Dim ZeroSalesDays].[Zero Sales Days].&[1] : [Dim ZeroSalesDays].[Zero Sales Days].&[30]}, {[Dim Period].[Period].[200702]}
)
Now they want to return [Dim ZeroSalesDays].[Zero Sales Days] value which was selected. How do I return that in the rows or columns. I can do order by and get the top record, but that will work only if I select a particular store and item, not for the entire set of all items/products.
with set
[Elapseddays] as
'order(
{[Dim ZeroSalesDays].[Zero Sales Days].&[1] : [Dim ZeroSalesDays].[Zero Sales Days].&[45]},
cint([Dim ZeroSalesDays].[Zero Sales Days].value), desc)
'
SELECT
{
[Measures].[Tagged], [Measures].[Void],[Measures].[On Shelf],
[Measures].[Last Tagged],[Measures].[Last Void]
} ON COLUMNS,
topcount(
NONEMPTYCROSSJOIN
(
{[Dim Product].[Item Id].&[4-DELMO -00090A]},
{[Dim Store].[StoreName].&[11733]},
{[Elapseddays]}
)
, 1)
ON ROWS
FROM sifdw
Any kind of help is appreciated.
Thank you in advance
Thank you,
Manish
Hi Manish,
Each row can include the last date of each individual Product/Store combination, like:
Code Snippet
SELECT
{[Measures].[Tagged], [Measures].[Void],[Measures].[On Shelf],
[Measures].[Last Tagged],[Measures].[Last Void] } ON COLUMNS,
Generate(([Dim Product].[Item Id].Children, [Dim Store].[StoreName].Children),
Tail(NONEMPTY(([Dim Product].[Item Id].CurrentMember, [Dim Store].[StoreName].CurrentMember,
{[Dim ZeroSalesDays].[Zero Sales Days].&[1] : [Dim ZeroSalesDays].[Zero Sales Days].&[45]}),
([Dim Period].[Period].[200702], [Measures].[Tagged])))) ON ROWS
FROM sifdw
|||Hi Deepak,
Somehow I was not able to get the query run successfully.
Let me attach the query what I have
SELECT
{
[Measures].[Last on Shelf]
} ON COLUMNS,
NONEMPTYCROSSJOIN
(
{[Dim Product].[Item Id].Children}
,{[Dim Store].[Store Id].children}
,{[Dim Date].[Date].children}
)
ON ROWS
FROM sifdw
WHERE
(
{[Dim ZeroSalesDays].[Zero Sales Days].&[1] : [Dim ZeroSalesDays].[Zero Sales Days].&[25]},
{[Dim ZeroSales].[Zero Sales].&[61]},
{[Dim ZeroSales].[Zero Sales Period].&[402006]},
{[Dim ZeroSales].[Team ID].&[4]}
)
Now in this given scenario, for each item / store combination, there can be multiple date. I want the most recent date for Item/store combination (Rows should display 3 columns - Item, Store and Date).
Thank you,
Manish
|||Hi Manish,
Could you explain the realtion between [Dim ZeroSalesDays] and [Dim Date] - the latter wasn't mentioned in your original description? And along which dimension is the most recent value (LastNonEmpty) found - since your original question related to determining the member along that dimension?
|||Hi Deepak,
Sorry for the confusion.
[Dim ZeroSalesDays] and [Dim Date] are 2 dimension.
In the fact table, lets say we have these 6 colums. Item, Store, Date, ZerosalesDays and period are dimension and on shelf is a measure.
Now in a query, for a period '5', between 1 & 45 zero sales days, I wan't the most recent record for that Item/Store combination along with the date. (It should return me 2nd record, if I change the zero sales days between 1 and 25 then it should return me 1st record and so on)
Item Store Date On Shelf ZeroSalesDays Period
00016 0800209 11/02/2006 2 24 5
00016 0800209 11/15/2006 5 37 5
00016 0800209 11/25/2006 2 47 5
I hope I made it clear. Let me know if you need any other information.
I am trying to use Generate function... but it's just spinning for ever.. May be I am missing something.
Thank you,
Manish
MDX Question on getting the top record for each....
I have scenario where a Item/Store combination can appear multiple times for the same period and to get the most recent record within a range ([Dim ZeroSalesDays].[Zero Sales Days]), I need to return the most current record. So I created measure with aggregation usage as last non empty.
So the below query works fine in that scenario.
SELECT
{
[Measures].[Tagged], [Measures].[Void],[Measures].[On Shelf],(Aggregation usage – sum)
[Measures].[Last Tagged],[Measures].[Last Void](Aggregation usage – Last Non Empty)
} ON COLUMNS,
NONEMPTYCROSSJOIN
(
{[Dim Product].[Item Id].Children},
{[Dim Store].[StoreName].Children}
)
ON ROWS
FROM sifdw
WHERE
(
{[Dim ZeroSalesDays].[Zero Sales Days].&[1] : [Dim ZeroSalesDays].[Zero Sales Days].&[30]}, {[Dim Period].[Period].[200702]}
)
Now they want to return [Dim ZeroSalesDays].[Zero Sales Days] value which was selected. How do I return that in the rows or columns. I can do order by and get the top record, but that will work only if I select a particular store and item, not for the entire set of all items/products.
with set
[Elapseddays] as
'order(
{[Dim ZeroSalesDays].[Zero Sales Days].&[1] : [Dim ZeroSalesDays].[Zero Sales Days].&[45]},
cint([Dim ZeroSalesDays].[Zero Sales Days].value), desc)
'
SELECT
{
[Measures].[Tagged], [Measures].[Void],[Measures].[On Shelf],
[Measures].[Last Tagged],[Measures].[Last Void]
} ON COLUMNS,
topcount(
NONEMPTYCROSSJOIN
(
{[Dim Product].[Item Id].&[4-DELMO -00090A]},
{[Dim Store].[StoreName].&[11733]},
{[Elapseddays]}
)
, 1)
ON ROWS
FROM sifdw
Any kind of help is appreciated.
Thank you in advance
Thank you,
Manish
Hi Manish,
Each row can include the last date of each individual Product/Store combination, like:
Code Snippet
SELECT
{[Measures].[Tagged], [Measures].[Void],[Measures].[On Shelf],
[Measures].[Last Tagged],[Measures].[Last Void] } ON COLUMNS,
Generate(([Dim Product].[Item Id].Children, [Dim Store].[StoreName].Children),
Tail(NONEMPTY(([Dim Product].[Item Id].CurrentMember, [Dim Store].[StoreName].CurrentMember,
{[Dim ZeroSalesDays].[Zero Sales Days].&[1] : [Dim ZeroSalesDays].[Zero Sales Days].&[45]}),
([Dim Period].[Period].[200702], [Measures].[Tagged])))) ON ROWS
FROM sifdw
|||Hi Deepak,
Somehow I was not able to get the query run successfully.
Let me attach the query what I have
SELECT
{
[Measures].[Last on Shelf]
} ON COLUMNS,
NONEMPTYCROSSJOIN
(
{[Dim Product].[Item Id].Children}
,{[Dim Store].[Store Id].children}
,{[Dim Date].[Date].children}
)
ON ROWS
FROM sifdw
WHERE
(
{[Dim ZeroSalesDays].[Zero Sales Days].&[1] : [Dim ZeroSalesDays].[Zero Sales Days].&[25]},
{[Dim ZeroSales].[Zero Sales].&[61]},
{[Dim ZeroSales].[Zero Sales Period].&[402006]},
{[Dim ZeroSales].[Team ID].&[4]}
)
Now in this given scenario, for each item / store combination, there can be multiple date. I want the most recent date for Item/store combination (Rows should display 3 columns - Item, Store and Date).
Thank you,
Manish
|||Hi Manish,
Could you explain the realtion between [Dim ZeroSalesDays] and [Dim Date] - the latter wasn't mentioned in your original description? And along which dimension is the most recent value (LastNonEmpty) found - since your original question related to determining the member along that dimension?
|||Hi Deepak,
Sorry for the confusion.
[Dim ZeroSalesDays] and [Dim Date] are 2 dimension.
In the fact table, lets say we have these 6 colums. Item, Store, Date, ZerosalesDays and period are dimension and on shelf is a measure.
Now in a query, for a period '5', between 1 & 45 zero sales days, I wan't the most recent record for that Item/Store combination along with the date. (It should return me 2nd record, if I change the zero sales days between 1 and 25 then it should return me 1st record and so on)
Item Store Date On Shelf ZeroSalesDays Period
00016 0800209 11/02/2006 2 24 5
00016 0800209 11/15/2006 5 37 5
00016 0800209 11/25/2006 2 47 5
I hope I made it clear. Let me know if you need any other information.
I am trying to use Generate function... but it's just spinning for ever.. May be I am missing something.
Thank you,
Manish
Wednesday, March 7, 2012
MDX query help !
I have the following query :
WITH
// get "5 period average sales"
MEMBER [Measures].[Sales_5Pavg] AS
'AVG({[Timeofday].[Dt].CURRENTMEMBER.LAG(3):[Timeofday].[Dt].CURRENTMEMBER},[Measures].[Sales])',FORMAT_STRING="#,##0.000"
// get the % which "Latest Sales > (Average of 5 periods Sales) "
MEMBER [Measures].[%up] AS
'([Measures].[Sales]-[Measures].[Sales_5Pavg])/[Measures].[C_5Pavg]',FORMAT_STRING="PERCENT"
SELECT {[Measures].[Sales],[Measures].[Sales_5Pavg],[Measures].[%up]} on 0,
ORDER (
FILTER (
[Product].[Product].CHILDREN,
([Measures].[Sales] > [Measures].[Sales_5Pavg])
),
[%up],
BDESC
) on 1
from SalesCube
where ([Timeofday].[Dt].&[2006-09-29T00:00:00]);
Sales Sales_5Pavg %up
productA 100 150 50%
productB 80 60 33.33%
productC 1200 1000 20%
.......etc
Above query get those products which sales greater than normal (i.e. 5 period average sales)
and sort the "greater than normal" percentage in decending order.
Since the query's period is date. May I know how to make the query more generic ?
e.g. adjust query so that it would be able to calculate base on month / quarter / year period ?
I have [Timeofday] dimension with the following hierarchy
[yr_dt] --> [Yr] --> [Hyr] --> [Qtr] --> [Mon] --> [Dt]
Please kindly advice and help. Thanks a lot !!
Hello. I am not sure from your MDX if you are using Analysis Services 2000 or 2005.
Here is a link to more information regarding Analysis Services 2005
http://sqljunkies.com/WebLog/mosha/archive/2006/10/25/time_calculations_parallelperiod.aspx
Here is a link to how you can solve this in Analysis Services 2000:
http://www.tomchester.net/
HTH
Thomas Ivarsson
Saturday, February 25, 2012
MDX query count of new customers with a new flag who purchased in this period and following peri
Hi all,
I would like some help with an MDX query that will give the following information - return the count of new customers for the current year that have a new customer flag set and then the count of those returning customers in the following years that have made purchases. Here is an example of the data I'm taking about -
CustomerID NewCustomer Year
1 1 2000
1 0 2001
2 1 2001
2 0 2002
1 0 2002
etc.
So, for the above I'm looking for something similar to the following -
Year 2000 New Customers = 1
Year 2001 New Customers = 1
Year 2001 Repeat Customers = 1
Year 2002 Repeat Customers = 2
Does this make sense and is it possible?
Thanks!
Brian
Please see this thread for the answer: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1225081&SiteID=1MDX query count of customers who purchased in prior period and this period
Hi there
I'm looking for help with an mdx query that will tell me how many of my customers are returning to purchase each period and thus by default how many existing customers haven't purchased this period.
So in English I want;
Count of distinct customers who were active in this period and were also active in prior period.
Or in T-SQL something like this
select count(*) from (Select distinct customer_id from fact_table where date = current period and exists (select distinct customer_id from fact_table where date = prior period))
I have a measure called distinct customer count and a dimension called DIm Customer which currently doesn't have customer_id as a level in any hierarchy, although it is the key field in this dimension, as I don't want to go to this level of detail if I can help it, not sure if this makes the above impossible.
Any ideas would be much appreciated.
Regards,
Derek
Hi Derek,
Here's a sample query for Adventure Works, which computes the count of customers with Internet Sales in both the current and prior Calendar periods - it's based on the count of common members being difference between the sum of member counts in each set and the distinct count of members across 2 sets:
>>
With Member [Measures].[ContinuingCustomers] as
Sum(LastPeriods(2, [Date].[Calendar].CurrentMember),
[Measures].[Customer Count]) -
Aggregate(LastPeriods(2, [Date].[Calendar].CurrentMember),
[Measures].[Customer Count])
select {[Measures].[Customer Count],
[Measures].[ContinuingCustomers]} on 0,
{[Date].[Calendar Year].&[2002]:
[Date].[Calendar Year].&[2004]} on 1
from [Adventure Works]
where [Product].[Subcategory].&[1]
--
Customer Count ContinuingCustomers
CY 2002 615 0
CY 2003 1,961 267
CY 2004 2,094 288
>>
|||Hi Deepak
Thanks very much that is exactly what I wanted, one thing though when I use this measure my cube response slows dramatically and my cpu use spikes, any idea why?
Cheers,
Derek
|||Derek, I suspect that it has to do with the performance of the dstinct count measure, but I'm not sure. Doing a SQL Profiler trace, with all query events selected, could help identify where the time is spent.|||Thanks again Deepak
I'll take a look at that, I may have to end up doing some of the work for this query in the data source view.
Cheers,
Derek
mdx query
I write the following MDX query that functions correctly:
WITH MEMBER [PERIOD CONTAB].[FY MONTH].[Totale] as
'AGGREGATE ( { [PERIOD CONTAB].[FY MONTH].&[2007-01-01T00:00:00] : [PERIOD CONTAB].[FY MONTH].&[2007-09-01T00:00:00] } )'
SELECT NON EMPTY { [Measures].[EUR] } ON COLUMNS ,
{
[Operating Cost]
,[COST ELEMENT].[MACRO COST].[Total Operating Cost]
,[COST ELEMENT].[MACRO COST].&[Capital Charge]
,[COST ELEMENT].[MACRO COST].[Total Contract Cost]
}
*
UNION (
{[PERIOD CONTAB].[FY MONTH].&[2007-01-01T00:00:00] :[PERIOD CONTAB].[FY MONTH].&[2007-09-01T00:00:00] }
, [PERIOD CONTAB].[FY MONTH].[Totale])
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
from [PMO_MDB]
If I try to insert the query inside Reporting Services substituting some data with query parameter in the following way I get an error:
WITH MEMBER [PERIOD CONTAB].[FY MONTH].[Totale] as
'AGGREGATE ( { STRTOMEMBER(@.FY_MONTH_START) : STRTOMEMBER(@.FY_MONTH_END) } )'
SELECT NON EMPTY { [Measures].[EUR] } ON COLUMNS ,
{
[Operating Cost]
,[COST ELEMENT].[MACRO COST].[Total Operating Cost]
,[COST ELEMENT].[MACRO COST].&[Capital Charge]
,[COST ELEMENT].[MACRO COST].[Total Contract Cost]
}
*
UNION (
{ STRTOMEMBER(@.FY_MONTH_START) : STRTOMEMBER(@.FY_MONTH_END) }
, [PERIOD CONTAB].[FY MONTH].[Totale])
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM ( SELECT ( STRTOSET(@.PROJECTSTREAM, CONSTRAINED) ) ON COLUMNS FROM [PMO_MDB])
WHERE ( IIF( STRTOSET(@.PROJECTSTREAM, CONSTRAINED).Count = 1, STRTOSET(@.PROJECTSTREAM, CONSTRAINED), [PROJECT].[STREAM].currentmember ) )
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
The query seems sintaticcally correct !
So what happened !
Here is the error:
TITLE: Microsoft Visual Studio
Query preparation failed.
ADDITIONAL INFORMATION:
Parser: The FY_MONTH_START parameter could not be resolved because it was referenced in an inner subexpression. (msmgdsrv)
BUTTONS:
OK
Having the same problem in reporting services. Have you found anything?|||Sounds like it's having a problem with the STRTOMEMBER function inside of the custom member definition. Since you know that your member will only be a single value, you could always write the query in dynamic mdx and pass the parameter values in. The top would look something like this:
Code Snippet
=" WITH MEMBER [PERIOD CONTAB].[FY MONTH].[Totale] as
'AGGREGATE ( { " + Parameters!FY_MONTH_START.Value + " : " + Parameters!FY_MONTH_END.Value + ") } )'
SELECT NON EMPTY { [Measures].[EUR] } ON COLUMNS , " +
It's a little tricky to get the designer to accept dynamic mdx. You have to write the original mdx query first. Then you have to click on the elipses for the dataset to bring up the dataset dialog. Then in the dialog, click the "f(x)" button to fill in the text. The dialog box that comes up will allow you to enter in the "=" sign and do the rest of your dynamic mdx.
|||Thanks for the reply
I solved simply removing the character ' in the member definition !
Don't know why .... but now it functions -)
WITH MEMBER [PERIOD CONTAB].[FY MONTH].[Totale] as AGGREGATE ( { " + Parameters!FY_MONTH_START.Value + " : " + Parameters!FY_MONTH_END.Value + ") } )
.....
Cosimo