• Ramya123
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Hi Every one,

 

I am facing below issue with trigger.Trigger is ment for the below functionality.

 

when I try to insert or update any record in one custom object(forecasting__c) and this insert/Update of record in Forecasting has to reflect in the another custom object called VP_Approval__c.

 

ERROR:

 

caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)

Trigger.VPApprovalCreateUpdateValues: line 92, column 1

 

In line 92 I have the below query:

 

public List<aggregateResult> forecastListQ = [select  sum(Manager_s_Amount__c) ManagerAmount, sum(Sales_executive_Amount__c) SalesAmonut, sum(Pipeline_Amount_ThisMonth__c) PipelineMonthAmount, sum(Amount__c) amount, Branch1__c, Product_Family1__c, Target_for__c, Months__c, Quarter__c, CALENDAR_YEAR(Close_Date__c) year from Forecasting__c where (RecordTypeID =: RecordTypeIDvalue) and  Branch1__c IN :branchSet and Branch1__c != null and Product_Family1__c IN :prodFamilySet and Product_Family1__c != null and Target_For__c IN :targetForSet and Target_For__c != null and Quarter__c IN :quarterSet and Quarter__c != null and CALENDAR_YEAR(Close_Date__c) IN :yearset and (RecordTypeID =: RecordTypeIDvalue) group by Product_Family1__c, Branch1__c,Target_for__c,Months__c,Quarter__c, CALENDAR_YEAR(Close_Date__c)]; 

 

This problem I am getting when I have more than 50000 records.

 

Please some one sugget me to avoid this error.

 

Thanks in Advance.