function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BerutielBerutiel 

how can i improve time execution of a query?

i 'm developing flex application , from there i execute queries.  .once in a while i get  query time out. i  can run query  several  times  and get query  time out but after several executions it works fine and retrieves all the records. i guess it's because of  cash  mechanism. than another day i run the query and it happens again. i get query time out for a few executions and  after several times it starts to work. again .my query is below. is my query problematic?  how can i improve time execution ? thanks,

 


<query xmlns="urn:partner.soap.sforce.com" xmlns:ns1="sobject.partner.soap.sforce.com">
<queryString>Select f.Year__c, f.Month__c, f.Product_TowerJazz__r.Id ,f.Id, f.Product_TowerJazz__c,
 f.Product_TowerJazz__r.NRE_Type__c,f.Product_TowerJazz__r.Name, f.Product_TowerJazz__r.Stage__c,
f.IsDeleted, f.Product_TowerJazz__r.Fab_Name__c, f.Product_TowerJazz__r.Flow_Group__c,
 f.Product_TowerJazz__r.oppProbability__c,f.ASP__c ,f.Qty_Probable__c ,
f.Revenue_Probable__c,  f.Account__r.Sales_Region__c, f.Account__r.Name, f.Account__c,  
f.Account__r.Sales_Level_1__c, f.Account__r.Sales_Level_2__c,
f.Account__r.Sales_Level_3__c, f.Account__r.Id,
  f.Forecast_Plan_Version__c From Forecast_Product__c f
WHERE   (f.Forecast_Plan_Version__c='a08500000040hpFAAQ' OR f.Forecast_Plan_Version__c='a08500000043sv4')
AND f.IsDeleted=false AND
f.Product_TowerJazz__r.RecordType.Name!='PLATFORM'  
AND f.Includes_In_FC__r.inactive__c=0
AND f.Opportunity__c
in (select Opportunity__c from Includes_in_fc__c fc  where fc.include_in_version__c =true AND fc.IsDeleted=false AND  Forecast_Plan_version__c = 'a08500000040hpFAAQ')  
AND ( (f.Year__c&lt;2012 AND f.Year__c&gt;2011) OR
(f.Year__c=2011 AND f.Year__c&lt;2012 AND f.Month__c&gt;=12)
OR (f.Year__c=2012 AND f.Year__c&gt;2011 AND f.Month__c&lt;=12)
OR (f.Year__c=2011 AND f.Year__c=2012 AND f.Month__c&gt;=12 AND f.Month__c&lt;=12 ) )  
AND f.Account__r.Planner__c='00550000001IxyaAAC' ORDER BY f.Product_TowerJazz__c
 

 

craigmhcraigmh

What are you trying to filter for with the Month/Year clauses? I have a feeling those can be cleaned up. OR statements really slow things down.