Using Long Text Area field in SELECT query returns less number of records - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Aditi JainAditi Jain 

Using Long Text Area field in SELECT query returns less number of records

Adding a Long Text Area field in a Select query then it returns wierd number of records then actual records available or returned when using select query without Long Text Area field.

However, adding more than one Long Text Area field in select query, number of records decreased even more as compared to those which returned with single Long Text Area field.

Let Say :

We have two Object A & B. B is A's child and have two long text area fields lat sat Long_Desc_1 and Long_Desc_2.

Number of A's record exists : more than 5000
Number of B's record exists : more than 3000

where around 2900 B's record belongs to a single Parent record.

Query results :
  1. Select Long_Desc_1 from B    (Returns exact 2000 records)
  2. Select Long_Desc_1, Long_Desc_2 from B    (Returns exact 1000 records)
  3. Select Id, (Select Long_Desc_1 from B) from A     (Returns around 3700 records)
  4. Select Id, (Select Long_Desc_1, Long_Desc_2 from B) from A  (Returns around 3200 records)
Not able to find any documented Limitation on Long Text Area field and not able to find any exact pattern for returned number of records.

Thanks
Joey Chan (Cloud Jedi)Joey Chan (Cloud Jedi)
Where are you doing the queries? Is it in VisualForce?
Aditi JainAditi Jain
@ Joey : In Apex class, and even tried to execute the same in Anonymous Block too. Result is same.
Joey Chan (Cloud Jedi)Joey Chan (Cloud Jedi)
It might be good to create a case in Salesforce regarding this. That definitely sounds like an odd behavior since the number of records shouldn't change regardless of what fields you selected.
Aditi JainAditi Jain
@Joey : Yes, it is something weird.
Joey Chan (Cloud Jedi)Joey Chan (Cloud Jedi)
It may be possible that Salseforce is doing some optimizations in the backend to prevent it from reaching the heap size. 

Are you getting the same behavior when using tools like the workbench?
https://workbench.developerforce.com/query.php
Aditi JainAditi Jain
@Joey : No its working fine in workbench. Showing correct number of records.

You are right, may be Salseforce is doing some optimizations to prevent it from reaching the heap size.
Joey Chan (Cloud Jedi)Joey Chan (Cloud Jedi)
It might be best to create a case since it definitely is misleading if they are trimming the number of records just to save on heap space.