ForceChallenges
ProblemsDailyNotesInterview
Sign in

Practice

All problemsSOQL practiceApex trigger challengesDaily challengeOpportunityTrigger.oldMapBefore UpdateBulkificationContactValidationGROUP BYSemi-JoinAccountBefore Insert

Interview questions

All questionsAdminAdministrationApexApex TriggerAsync ApexDevelopmentField ServiceField ServiceIntegrationLwc

By company

DeloitteSalesforceAccentureInfosysPwCCognizant

Learn

Study notes

ForceChallenges

AboutContact usPrivacy PolicyTerms of ServiceFor AI assistants (llms.txt)
© 2026 ForceChallenges · Salesforce SOQL & Apex trigger practice
Integration questions56 of 100
IntegrationMedium 2 min read

How does Heroku Connect bridge Salesforce data with Heroku Postgres databases for enterprise applications?

Answer

Basics: Heroku apps work best with a relational database, while Salesforce data sits behind APIs with call limits. Heroku Connect copies the Salesforce data you choose into Postgres (usually in a schema named salesforce), so a web app, a customer portal or an analytics job reads and writes with SQL instead of calling the Salesforce API. It is part of the Salesforce Platform Services offering that sits beside Heroku, and it is billed by plan according to the number of mapped rows.

How it works:

  1. Provision the Heroku Connect add-on and attach it to a Heroku Postgres database.
  2. Authorize it to a Salesforce org with OAuth, using a dedicated integration user.
  3. Create mappings. Each mapping links one Salesforce object to one Postgres table and lists the fields to copy.
  4. Heroku Connect creates the tables with columns for each field plus housekeeping columns such as sfid, id, isdeleted, systemmodstamp, _hc_lastop and _hc_err.
  5. Salesforce to Postgres: Heroku Connect reads changes using the Salesforce APIs, by polling or by accelerated polling that uses push notifications.
  6. Postgres to Salesforce: triggers log each row change in a trigger log table, and Heroku Connect sends those changes to Salesforce through the API.

Advanced / deep dive: Heroku Connect consumes Salesforce API calls and Bulk API capacity, so very large or chatty mappings need budgeting. Conflicts follow a last-write-wins model, and there is no cross-system transaction. Record ownership and sharing are not replicated, because the integration user's access defines what is copied. Alternatives are Salesforce Connect with OData (data stays in place, with query latency on every read), Pub/Sub API or Change Data Capture (event streaming with no stored copy), and middleware such as MuleSoft. Choose Heroku Connect when the app needs relational joins, high read volume or offline-tolerant access.

Code / config example:

sql
-- Heroku Postgres: insert a contact; Heroku Connect pushes it to Salesforce.
INSERT INTO salesforce.contact (firstname, lastname, email)
VALUES ('Ada', 'Lovelace', 'ada@example.com');
-- Check status: _hc_lastop = 'PENDING' | 'SYNCED' | 'FAILED'
SELECT id, sfid, _hc_lastop, _hc_err FROM salesforce.contact WHERE email = 'ada@example.com';

Hidden gotchas & must-remember points:

  • Latency is seconds to minutes depending on the polling mode, not sub-second. Verify current intervals in the Heroku docs.
  • Rows inserted from Postgres have no sfid until the sync completes; use an external ID to make later upserts reliable.
  • Salesforce validation rules, required fields and triggers still run, and failures appear in _hc_err rather than in your app.
  • It is not Heroku External Objects. External Objects use Salesforce Connect and do not copy data.
  • Deleting a mapping or its data in Postgres does not delete Salesforce data unless the delete is replicated.
  • A single integration user determines field-level security for everything that is synced.

Best practice: Map only the objects and fields you need, use external IDs, and monitor the sync status and error columns.

IntegrationHeroku ConnectPostgres Synchronization
Practice SOQL & Apex
PreviousHow are organization API rate limits calculated, and what happens when integration volume exceeds thresholds?Next What operational visibility do Event Monitoring log files provide to security teams auditing integration activity?

More Integration questions

  • How do PushTopics combine SOQL query criteria with real-time streaming notifications in Salesforce?
  • How do webhook security mechanisms verify the authenticity of incoming HTTP notifications from external systems?
  • How do federated identity and SAML single sign-on streamline authentication across enterprise integration landscapes?
  • How do CORS settings permit authorized web applications to perform cross-origin REST requests against Salesforce?
  • How do rate limiting and throttling mechanisms protect Salesforce endpoints from excessive traffic spikes?