Hi,
We have a report query performance issue (due to query run time in SQL Server 2008 Database) and we want to overcome this issue by altering the way query is generated by BO/WebI. Currently our BO 4.0 WebIntelligence Report generates a query something similar to this:
SELECT
*
FROM
DIM_PRODUCT INNER JOIN FCT_SALES ON (FCT_SALES.PRODUCT_ID = DIM_PRODUCT.PRODUCT_ID)
INNER JOIN DIM_DATE ON (FCT_SALES.DATE_ID = DIM_DATE.DATE_ID)
WHERE
DIM_DATE.DATE_ID between dateadd(qq,DATEDIFF(qq,0,GETDATE() ) - 5,0) and dateadd(qq,DATEDIFF(qq,0,GETDATE()),0) -1 )
AND
DIM_PRODUCT.PROMOTION_FLG = 'Y'
Issue Description:
In the WHERE clause, our query picks the last five quarters of data from current date to generate the query result set for BO report. It takes about 5 minutes to run this query. What we have observed is that database function DATEDIFF is causing the issue, If we replace it with a static value (value - 454, which is generated by SQL Server for today's date) then the query runs in just 3 seconds.
For us to improve performance of this query, we need to somehow compute value for " DATEDIFF(qq,0,GETDATE() ) " and use this value in our BO generated query.
Thank you in advance for your valuable suggestions.
Regards,
Raj