Skip to main content
17 votes
Accepted

How to get MAX value using SOQL when there are more than 50,000 rows

Take out the MAX from your query: SELECT Auto_Number__c FROM Opportunity ORDER BY Auto_Number__c DESC LIMIT 1
sfdcfox's user avatar
  • 502k
6 votes

500K record transaction: Trigger vs Scheduled Apex?

Triggers run against batches of (up to) 200 records, no matter if it's 200 records or 20,000,000 records. The API won't allow batches larger than 2,000, and this is typically unusual. Most data loads ...
sfdcfox's user avatar
  • 502k
4 votes

Owner Data Skew Prevention for smaller orgs

The risk of ownership skew has to do with sharing calculations, especially moving users in the role hierarchy. You can read more about it in Ownership Skew. If this isn't a commonly performed ...
sfdcfox's user avatar
  • 502k
4 votes
Accepted

Data skew exists whereby the number of matching rows is very large

You only have one query, so the culprit is pretty clear: SELECT Id,OppLineItemsCount__c, (SELECT Id FROM Opportunitylineitems) FROM Opportunity WHERE StageName IN: mapOCRRequiredStages.keySet() ...
David Reed's user avatar
  • 93.7k
4 votes
Accepted

System.LimitException: Too many query rows: 50001 - How to solve it with a batch?

On the face of it, a Batch on Contract would be appropriate. I would write the batch to iterate the Contracts and have the execute perform the aggregate query and related processing. Your aggregate ...
Phil W's user avatar
  • 38.1k
4 votes
Accepted

Treatment of large data sets (>1M) in standard objects

It doesn't. Standard objects and Big Objects are separate kinds of database entity. Big Objects are custom objects you can create to store massive amounts of data, while accepting certain limitations ...
David Reed's user avatar
  • 93.7k
3 votes
Accepted

Aggregate Query on 900K records - how to do this?

It seems to me this is very like your previous question, and likely has the same basic answer... The issue I see in your first batch is that the aggregate query does not limit the query for "maplastY"...
Phil W's user avatar
  • 38.1k
3 votes

Query not selective error is happening only in Trigger context but not in VF,Batch. Is this expected?

There are unique limitations when running large, non-selective queries in a trigger context: Developers receive an error message when a non-selective query in a trigger executes against an object ...
David Reed's user avatar
  • 93.7k
2 votes
Accepted

Real time synch with external application on insert and update of frequently changing records

You have a classic use case for Change Data Capture here. Receive near-real-time changes of Salesforce records, and synchronize corresponding records in an external data store. Change Data Capture ...
Jayant Das's user avatar
  • 30.7k
2 votes
Accepted

Dynamic Queries on Dynamic Objects at Volume

This is a tricky one, because a) it's rather an opinion-based question in a lot of ways and b) there are only so many design/implementation patterns available to you in the Salesforce context. It's ...
Phil W's user avatar
  • 38.1k
2 votes
Accepted

Alternate of Protected Custom Settings In an AppExchange Managed Package for Large Configuration Data

I think I would address this in two parts: Have a protected Custom Metadata Type record that is set up by the installer for the managed package to contain an encryption/decryption key (and whatever ...
Phil W's user avatar
  • 38.1k
2 votes
Accepted

Working with large data volume

In Salesforce, you can only update 10,000 records in a transaction, and that's via Apex. Otherwise, using the API and other tools, you're limited to just 200 records per transaction. So, at no point ...
sfdcfox's user avatar
  • 502k
2 votes
Accepted

Case Object with 2 Self Lookups to Cases - Considerations

One area to think about (not sure how important) is the Account Case relations. With 1.6m records, I'd be wary of hitting the 10k or less best practice for lookups( and master-details) that have ...
John's user avatar
  • 445
2 votes
Accepted

How to store information on Product stocks with variable number of warehouses

I think you've outlined all the possible solutions to storing data in Salesforce. Because of your requirements which include using standard reporting and automation, you can't consider all the ...
Daniel Hoechst's user avatar
1 vote

How indexes work when the WHERE clause contains AND

In the first link, the part you quoted was talking only about custom indexes. Standard indexes use the rules in the preceding paragraph: Standard Indexed Fields Used if the filter matches less than ...
sfdcfox's user avatar
  • 502k
1 vote
Accepted

Custom Indexes of Null Records

In Salesforce, one index is created for each field that meets a certain criteria. Note that we're talking about database table indexes, not search indexes, which are a different topic. We'll only be ...
sfdcfox's user avatar
  • 502k
1 vote

Difference between Salesforce Connect and Heroku Connect

There are 4 orgs. 1 main org 2 sales orgs 1 service org. They want to centralize data that is created on boths sales and service orgs. In order to do that, they need to use Heroku Connect as the ...
ransommule's user avatar
1 vote
Accepted

Difference between Salesforce Connect and Heroku Connect

The key difference between Heroku Connect and Salesforce Connect is Heroku Connect synchronizes records between a Heroku Database and Salesforce (a copy of the data is kept on both systems). ...
KarlLivesey's user avatar
1 vote

Testing bulk clone operation

You cannot test this in a unit test that actually performs DML. The DML rows limit is 10,000 in a single transaction, and even using Test.startTest() and Test.stopTest() to execute your batch class ...
David Reed's user avatar
  • 93.7k
1 vote

Bulk deletion of Case Team Member records, data skew, and performance issues

I have performed couple of bulk delete and Sharing recalculation related activities and here is my suggestions. Usually, this exercise needs to perform in a full copy sandbox though performance can ...
Santanu Boral's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible