You need to sign in to do that
Don't have an account?
chandrasekhar reddy
Selective threshold question?
Hi,
My Lead table has 1300000 records (<2 million). I am using beloq SOQL query.
Above query returns 200000 records. Which is exceeding selective threshold limit. Because for 1300000 records, selective threshold limit is 115000 (10% in first million records+ 5% in rest of the records). But my query returns 200000 records. when the query retutns more than selective threshold, indexes will not be considered and query takes long time to return the result. How can i avoid this issue?
If i use LIMIT as below, still the indexes on statecode will be ignored?
My Lead table has 1300000 records (<2 million). I am using beloq SOQL query.
select id, company, phone, statecode from Lead where statecode='AB'Here statecode is custom field and has been indexed.
Above query returns 200000 records. Which is exceeding selective threshold limit. Because for 1300000 records, selective threshold limit is 115000 (10% in first million records+ 5% in rest of the records). But my query returns 200000 records. when the query retutns more than selective threshold, indexes will not be considered and query takes long time to return the result. How can i avoid this issue?
If i use LIMIT as below, still the indexes on statecode will be ignored?
select id, company, phone, statecode from Lead where statecode='AB' LIMIT 100000Please suggest me. Thanks!
I think you should use more than two filter.
Try like this.
Even if Phone != '' is applied, query returns same number of records.
You can use any other field instead of Phone for selective query.
For more information check the below link.
https://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_VLSQ.htm
you can use one more filter like created date < some date or created by particular user.
If i apply one more filter lke created date < some date, then i get only few records but not all 200000 records. If i apply date filter then i miss records which i dont want. Please suggest me. As am getting 200000 records, will SFDC would ignore indexes while searching ? Thanks!
In this case you need to write batch class.
see the link below.
https://developer.salesforce.com/forums?id=906F000000090EEIAY
A maximum of 50 million records can be returned in the Database.QueryLocator object.so you use Database.QueryLocator object to query records.
Go through batch apex governor limits once.
2nd solution : you can query records in multiple steps then do the processing you want.For example first query records till last year, then query records this year.now you can do processing.