Showing posts with label performance. Show all posts
Showing posts with label performance. Show all posts

Thursday, March 29, 2012

Count Query Performance

I have a query that seems simple but apparently is not.Any thoughts on performance optimization would be helpful.The following query works, but it takes 20 minutes to run.

WITH

MEMBER [Measures].[90-100] AS

'COUNT( FILTER( EXISTING [Student].[Student].[Student].Members, [Measures].[Avg Attendance] >.90)

)'

MEMBER [Measures].[80-90] AS

'COUNT(FILTER( EXISTING [Student].[Student].[Student].Members, [Measures].[Avg Attendance] >.80

AND [Measures].[Avg Attendance] <.90)

)'

SELECT

{[Measures].[90-100], [Measures].[80-90]} ON COLUMNS,

NON EMPTY EXISTING [School].[By District Area].[School].MEMBERS ON ROWS

FROM [Student Engagement]

There has got to be a better way. My guess is that somehow I need to limit the resulting set of schools * students that get counted to only the nonempties, but I’m not sure how to formulate the MDX.

Any ideas?

Chris

Instead of EXISTING in the calculated measures, which isn't needed unless other attributes of the [Student] dimension are placed on query axes, you could try NonEmpty(), like:

WITH

MEMBER [Measures].[90-100] AS

COUNT( FILTER( NonEmpty([Student].[Student].[Student].Members,

{[Measures].[AttendFactCount]}),

[Measures].[Avg Attendance] >.90)

)

MEMBER [Measures].[80-90] AS

COUNT(FILTER( NonEmpty([Student].[Student].[Student].Members,

{[Measures].[AttendFactCount]}),

[Measures].[Avg Attendance] >.80

AND [Measures].[Avg Attendance] <.90)

)

where [AttendFactCount] is some cube measure from the relevant measure group (assuming that [Avg Attendance] is a calculated measure like: [PresentSum] / [AttendFactCount]).|||

Deepak-

Thank you! Inserting the “NonEmpty” worked. The query returned in 5 seconds.

The question is why.Given, that I had “Non Empty” in the select statement and the NonEmptyBehavior(NEB) set to [Measures].[Absence] for the calculated member [Measures].[Avg Attendance] (Avg Attendance = Absence/ Enrollment) in the initial query,I would have assumed that the query engine would suppress the non empties automatically based on the NEB.Can you help me understand?

Chris

|||

Chris,

The “Non Empty” in the select statement wouldn't help because, if the 2 calculated measures are simply defined as counts, they could be 0, but never empty. Regarding the NEB, I'm not sure; but it could be that the query optimizer doesn't infer from the condition: [Avg Attendance] > 0.9 that [Avg Attendance] isn't empty. You could check whether changing the condition to: Not IsEmpty([Avg Attendance]) And [Avg Attendance] > 0.9 speeds up the query.

Friday, February 17, 2012

Cost of re-using Dialogs - Why recycle them?

After lots of testing I have found that re-using dialogs improves performance significantly, however I cannot fathom out what is the cost of re-using them. Performance does not come for free hene why I feel there is a cost. Can anyone shed any light on the cost of re-using dialogs? Also why should you re-cycle them? What benefits does recycling dialogs have?

Many thanks

David

If your message exchanges map a business transaction, then the benefits of individual dialogs (mainly precise error semantics per business transaction) are not to be neglected. If you just push data from one site to the other (replication like) then reusing/recycling dialogs is the way to go.

The main cost is the complexity of code (more difficult to get right, to maintain, more bugs etc etc).

Recycling dialogs is needed to minimize the cost of 'loosing' one dialog. Dialogs can error, because of application bugs (eg. a badly formatted XML payload), because of human administrator error, because of hardware failures (backup back in time with to data loss). When a dialog is errored, there is the potential of a large queue of pending messages to be still not transmitted and in the sender's sys.transmission_queue to be lost, or at least to have to to be re-transmitted (app code has to read sys.transmission_queue and re-send them on a new dialog). Periodic re-cycle of dialogs minimizes this potential.