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

SOQL query return records and return list size does not match

Hi, I have a code like below

list<Lead> lstLead = [select Id, Name from Lead];  //line 8

system.dedug('----size---'+lstLead.size()) ;  // line 9


In debug log



Line 8: returns 16120 Rows.

Line 9: debug prints==>    ----size---16074


How this is possible? Can anyone help me?




If only the two lines, it's not possible. So, why not paste the entire codes for the discussion ?

The code is below


global with sharing class LeadGaugeController{
   global static List<AggregateResult> getData() {
        return[select COUNT(id) numLeads , Status stg
               FROM Lead WHERE Createddate < LAST_WEEK and Status ='Open' GROUP BY Status LIMIT 1];
       public List<Lead> getStuck_Leads() {
               list<Lead> lstLead = [select FirstName,LastName, Name,Title,Company,Street,LeadSource,Delivery_Street__c,Email,Owner.Name,Rating,IsUnreadByOwner
               FROM Lead WHERE Createddate < LAST_WEEK and Status ='Open'];
               return lstLead;



debug log



20:52:14.106 (106346000)|SOQL_EXECUTE_BEGIN|[9]|Aggregations:0|select FirstName, LastName, Name, Title, Company, Street, LeadSource, Delivery_Street__c, Email, Owner.Name, Rating, IsUnreadByOwner from Lead where (Createddate < LAST_WEEK and Status = 'Open')
20:52:15.284 (1284506000)|SOQL_EXECUTE_END|[9]|Rows:16120
20:52:15.373 (1373366000)|SYSTEM_METHOD_ENTRY|[11]|LIST<Lead>.size()
20:52:15.373 (1373434000)|SYSTEM_METHOD_EXIT|[11]|LIST<Lead>.size()
20:52:15.373 (1373469000)|SYSTEM_METHOD_ENTRY|[11]|String.valueOf(Object)
20:52:15.373 (1373481000)|SYSTEM_METHOD_EXIT|[11]|String.valueOf(Object)
20:52:15.373 (1373504000)|SYSTEM_METHOD_ENTRY|[11]|System.debug(ANY)
20:52:15.373 (1373511000)|USER_DEBUG|[11]|DEBUG|---size-----16074
20:52:15.373 (1373517000)|SYSTEM_METHOD_EXIT|[11]|System.debug(ANY)
20:52:15.373 (1373526000)|SYSTEM_MODE_EXIT|false
It should be the same. Weird.

Thank you. But unfortunately it is not same. What should I do now?


Weird, but interesting.


I want to know what's the difference.

If I were you, I will try to limit the query and find out what causes the difference.

list<Lead> lstLead = [select ...
               FROM Lead WHERE Createddate < LAST_WEEK and Createddate > LAST_MONTH and
               Status ='Open'];


In Developer console, I tried the query what I posted. It is showing same records in "Return Rows" and "---size---". But Visual force page displaying different in "---size---"(less records).