SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler offline
Data Design Tips for Developing
Robust Apps on Force.com
Lessons learned while developing a finance system on
Force.com
Steven Lawrance, Salesforce.com, Lead Member of the Technical Staff
Safe harbor
Safe harbor statement under the Private Securities Litigation Reform Act of 1995:
This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties
materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results
expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be
deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other
financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any
statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services.
The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new
functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our
operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any
litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our
relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our
service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to
larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is
included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent
fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor
Information section of our Web site.
Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently
available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions
based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these
forward-looking statements.
Steven Lawrance
Lead Member of the Technical Staff
Session Agenda
▪ Designing within limits
▪ Handing updates to arbitrary numbers of records
▪ Demonstration
▪ Executing aggregate queries with limits and offsets
▪ Sorting complex objects
▪ Q&A
Designing within limits
▪ Design decisions should consider resource availability
• Custom object limit
• Custom tab limit
• Storage limits
• API call limits
Designing within limits
Designing within limits
▪ Scarce
• Record storage

▪ Plentiful
• Custom objects
• Tabs
• Apex code lines

▪ Selection of limits to optimize
• Record storage limits were selected for optimization in this project.
• Runtime computation was favored over temporary storage in a custom object.
Designing within limits
Ne
w

Reconciliation
1

∞

Opportunity
(Donation)

∞

Primary
Campaign

1

Campaign
∞

1

Default
Designation
∞

1

∞
1

Finance Batch

Donation
Designation

∞

1

Designation
Handing updates to arbitrary numbers of records
@future, Maps, and Visualforce are your friends.
▪ @future method: Asynchronously update batches of records.
• Update only up to the DML execution and record limits.

▪ Maps: Identify batches in the keys and changes in the values.
• @future private static void runLater(Map<String,String> batchUpdateValues)

▪ Visualforce: Use to re-invoke the next @future method call, if needed.
• @future methods cannot be called from a @future method.
Handing updates to arbitrary numbers of records
Visualforce page sends groups of batches to the @future method
▪ Page checks the donation update status during the page load.
• Updates required: Call the @future method and reload the page every 4 seconds.
• Updates in progress: Reload the page every 4 seconds.
• Complete: Display the regular user interface.

▪ The @future method updates donations until it gets to the DML limits.
• Set the donation update status at the end of @future method.
Handing updates to arbitrary numbers of records
Processing within @future

Input from Visualforce
Key

Value

For each key,

update each donation

to the target value

Credit Card
AmEx
2013-11-02

Finance Batch
a0nK0000000FAY
8

Credit Card
AmEx
2013-11-02

Fred Smith
AmEx
2013-11-02
$5.00

Finance Batch
a0nK0000000FAY8

Alex Jones
AmEx
2013-11-02
$10.00

Finance Batch
a0nK0000000FAY8

Check
2013-11-02
B123456
.
.
.

Finance Batch
a0nK0000000FAY
9
.
.
.

.
.
.

Catherine Katz
AmEx
2013-11-02
$10.00

.
.
.
Demonstration
Executing aggregate queries with limits and offsets
▪ Aggregations can return at most 500 rows per query.
▪ By using LIMIT and OFFSET, it’s possible to query more than 500
aggregated rows.
▪ In an aggregate query, the OFFSET can’t be 2000 or higher.
Executing aggregate queries with limits and offsets
for (Integer batchOffset = 0; batchOffset < 2000;) {
Integer aggregateBatchCount = 0, aggregateBatchSize = 500;
for (AggregateResult donationBatch : [SELECT … FROM … WHERE …
GROUP BY … ORDER BY … NULLS FIRST
LIMIT :aggregateBatchSize OFFSET :batchOffset]) {
aggregateBatchCount++;
…
}
if (aggregateBatchCount < aggregateBatchSize) { break; }
else { batchOffset += aggregateBatchCount; }
}
Executing aggregate queries with limits and offsets
Break apart disjunctions into separate queries if it’s faster.
▪ If your query takes too long to execute and makes use of ‘OR’, then try
splitting it into multiple queries that don’t use ‘OR’
SELECT … FROM Donation_Designation__c
WHERE Donation__r.CloseDate >= :startDate
AND Donation__r.CloseDate < :endDatePlusOne
AND (Donation__r.Fin_Batch__r.Rec__c = :recId
OR Donation__r.Batch__c = NULL
OR Donation__r.Batch__r.Status__c = 'Committed')
GROUP BY …
ORDER BY …
LIMIT … OFFSET …
Executing aggregate queries with limits and offsets
▪ The query plan in the underlying database is much more efficient when
all filters are conjunctive (joined with ‘AND’).
SELECT … FROM Donation_Designation__c
WHERE Donation__r.CloseDate >= :startDate
AND Donation__r.CloseDate < :endDatePlusOne
AND Donation__r.Fin_Batch__r.Rec__c = :recId
GROUP BY …
ORDER BY …
LIMIT … OFFSET …
Executing aggregate queries with limits and offsets
▪ Index range scans are faster than table scans.
▪ Use of ‘OR’ can lead to table scans.
▪ Salesforce.com can create an index for frequently filtered fields.
Sorting complex objects
▪ Before Winter ‘14, using a Map<String,ComplexObject> and a
List<String> to call List.sort() was a way to sort without running out of
script statements. The properties exist in the String key in the order to
sort by.
▪ In Winter ’14 and beyond, the recommended approach is to implement
the Comparable interface and call List.sort() on a List of your object.
• public class ComplexObject implements Comparable {
…
public Integer compareTo(Object compareTo) { /* implementation here */ }
}
Steven Lawrance
Lead Member of the
Technical Staff
Data Design Tips for Developing Robust Apps on Force.com

Mais conteúdo relacionado

Semelhante a Data Design Tips for Developing Robust Apps on Force.com

Salesforce Winter22 Release Overview
Salesforce Winter22 Release OverviewSalesforce Winter22 Release Overview
Salesforce Winter22 Release OverviewSara Sali
 
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStoreDeveloping Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStoreTom Gersic
 
Get ready for your platform developer i certification webinar
Get ready for your platform developer i certification   webinarGet ready for your platform developer i certification   webinar
Get ready for your platform developer i certification webinarJackGuo20
 
Building Visualforce Custom Events Handlers
Building Visualforce Custom Events HandlersBuilding Visualforce Custom Events Handlers
Building Visualforce Custom Events HandlersSalesforce Developers
 
Understanding the Salesforce Architecture: How We Do the Magic We Do
Understanding the Salesforce Architecture: How We Do the Magic We DoUnderstanding the Salesforce Architecture: How We Do the Magic We Do
Understanding the Salesforce Architecture: How We Do the Magic We DoSalesforce Developers
 
Bootstrapping DX in Your Enterprise - AutoRABIT at TrailheaDX
Bootstrapping DX in Your Enterprise - AutoRABIT at TrailheaDXBootstrapping DX in Your Enterprise - AutoRABIT at TrailheaDX
Bootstrapping DX in Your Enterprise - AutoRABIT at TrailheaDXAutoRABIT
 
Understanding Multitenancy and the Architecture of the Salesforce Platform
Understanding Multitenancy and the Architecture of the Salesforce PlatformUnderstanding Multitenancy and the Architecture of the Salesforce Platform
Understanding Multitenancy and the Architecture of the Salesforce PlatformSalesforce Developers
 
Mbf2 salesforce webinar 2
Mbf2 salesforce webinar 2Mbf2 salesforce webinar 2
Mbf2 salesforce webinar 2BeMyApp
 
Building Complex Traversing & Branching Apps Using Visual Workflows and Apex
Building Complex Traversing & Branching Apps Using Visual Workflows and ApexBuilding Complex Traversing & Branching Apps Using Visual Workflows and Apex
Building Complex Traversing & Branching Apps Using Visual Workflows and ApexSalesforce Developers
 
Building Apps Faster with Lightning and Winter '17
Building Apps Faster with Lightning and Winter '17Building Apps Faster with Lightning and Winter '17
Building Apps Faster with Lightning and Winter '17Mark Adcock
 
Building apps faster with lightning and winter '17
Building apps faster with lightning and winter '17Building apps faster with lightning and winter '17
Building apps faster with lightning and winter '17Salesforce Developers
 
Enhance salesforce application performance using lightning platform cache
Enhance salesforce application performance using lightning platform cacheEnhance salesforce application performance using lightning platform cache
Enhance salesforce application performance using lightning platform cacheMohith Shrivastava
 
Exploring SQL Server Azure Database Relationships Using Lightning Connect
Exploring SQL Server Azure Database Relationships Using Lightning ConnectExploring SQL Server Azure Database Relationships Using Lightning Connect
Exploring SQL Server Azure Database Relationships Using Lightning ConnectSalesforce Developers
 
Transition to the Lightning Experience: Pro Tips, Tools and a Transition Stra...
Transition to the Lightning Experience: Pro Tips, Tools and a Transition Stra...Transition to the Lightning Experience: Pro Tips, Tools and a Transition Stra...
Transition to the Lightning Experience: Pro Tips, Tools and a Transition Stra...Shell Black
 
The Need for Speed: Building Reports That Fly
The Need for Speed: Building Reports That FlyThe Need for Speed: Building Reports That Fly
The Need for Speed: Building Reports That FlySalesforce Developers
 
Modeling and Querying Data and Relationships in Salesforce
Modeling and Querying Data and Relationships in SalesforceModeling and Querying Data and Relationships in Salesforce
Modeling and Querying Data and Relationships in SalesforceSalesforce Developers
 
Build System Performance Data Analytics Using Wave
Build System Performance Data Analytics Using WaveBuild System Performance Data Analytics Using Wave
Build System Performance Data Analytics Using WaveSalesforce Developers
 

Semelhante a Data Design Tips for Developing Robust Apps on Force.com (20)

Salesforce Winter22 Release Overview
Salesforce Winter22 Release OverviewSalesforce Winter22 Release Overview
Salesforce Winter22 Release Overview
 
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStoreDeveloping Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore
 
Get ready for your platform developer i certification webinar
Get ready for your platform developer i certification   webinarGet ready for your platform developer i certification   webinar
Get ready for your platform developer i certification webinar
 
Building Visualforce Custom Events Handlers
Building Visualforce Custom Events HandlersBuilding Visualforce Custom Events Handlers
Building Visualforce Custom Events Handlers
 
Understanding the Salesforce Architecture: How We Do the Magic We Do
Understanding the Salesforce Architecture: How We Do the Magic We DoUnderstanding the Salesforce Architecture: How We Do the Magic We Do
Understanding the Salesforce Architecture: How We Do the Magic We Do
 
Einstein Analytics for Developers
Einstein Analytics for DevelopersEinstein Analytics for Developers
Einstein Analytics for Developers
 
Introduction to Force.com
Introduction to Force.comIntroduction to Force.com
Introduction to Force.com
 
Bootstrapping DX in Your Enterprise - AutoRABIT at TrailheaDX
Bootstrapping DX in Your Enterprise - AutoRABIT at TrailheaDXBootstrapping DX in Your Enterprise - AutoRABIT at TrailheaDX
Bootstrapping DX in Your Enterprise - AutoRABIT at TrailheaDX
 
Understanding Multitenancy and the Architecture of the Salesforce Platform
Understanding Multitenancy and the Architecture of the Salesforce PlatformUnderstanding Multitenancy and the Architecture of the Salesforce Platform
Understanding Multitenancy and the Architecture of the Salesforce Platform
 
Mbf2 salesforce webinar 2
Mbf2 salesforce webinar 2Mbf2 salesforce webinar 2
Mbf2 salesforce webinar 2
 
Winter 14 Release Developer Preview
Winter 14 Release Developer PreviewWinter 14 Release Developer Preview
Winter 14 Release Developer Preview
 
Building Complex Traversing & Branching Apps Using Visual Workflows and Apex
Building Complex Traversing & Branching Apps Using Visual Workflows and ApexBuilding Complex Traversing & Branching Apps Using Visual Workflows and Apex
Building Complex Traversing & Branching Apps Using Visual Workflows and Apex
 
Building Apps Faster with Lightning and Winter '17
Building Apps Faster with Lightning and Winter '17Building Apps Faster with Lightning and Winter '17
Building Apps Faster with Lightning and Winter '17
 
Building apps faster with lightning and winter '17
Building apps faster with lightning and winter '17Building apps faster with lightning and winter '17
Building apps faster with lightning and winter '17
 
Enhance salesforce application performance using lightning platform cache
Enhance salesforce application performance using lightning platform cacheEnhance salesforce application performance using lightning platform cache
Enhance salesforce application performance using lightning platform cache
 
Exploring SQL Server Azure Database Relationships Using Lightning Connect
Exploring SQL Server Azure Database Relationships Using Lightning ConnectExploring SQL Server Azure Database Relationships Using Lightning Connect
Exploring SQL Server Azure Database Relationships Using Lightning Connect
 
Transition to the Lightning Experience: Pro Tips, Tools and a Transition Stra...
Transition to the Lightning Experience: Pro Tips, Tools and a Transition Stra...Transition to the Lightning Experience: Pro Tips, Tools and a Transition Stra...
Transition to the Lightning Experience: Pro Tips, Tools and a Transition Stra...
 
The Need for Speed: Building Reports That Fly
The Need for Speed: Building Reports That FlyThe Need for Speed: Building Reports That Fly
The Need for Speed: Building Reports That Fly
 
Modeling and Querying Data and Relationships in Salesforce
Modeling and Querying Data and Relationships in SalesforceModeling and Querying Data and Relationships in Salesforce
Modeling and Querying Data and Relationships in Salesforce
 
Build System Performance Data Analytics Using Wave
Build System Performance Data Analytics Using WaveBuild System Performance Data Analytics Using Wave
Build System Performance Data Analytics Using Wave
 

Mais de Salesforce Developers

Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSalesforce Developers
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceMaximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceSalesforce Developers
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base ComponentsSalesforce Developers
 
TrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsTrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsSalesforce Developers
 
Why developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaWhy developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaSalesforce Developers
 
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentCodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentSalesforce Developers
 
CodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsCodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsSalesforce Developers
 
Enterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsEnterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsSalesforce Developers
 
TrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsTrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsSalesforce Developers
 
Lightning web components - Episode 4 : Security and Testing
Lightning web components  - Episode 4 : Security and TestingLightning web components  - Episode 4 : Security and Testing
Lightning web components - Episode 4 : Security and TestingSalesforce Developers
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilitySalesforce Developers
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce dataSalesforce Developers
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionSalesforce Developers
 
Migrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPMigrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPSalesforce Developers
 
Scale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceScale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceSalesforce Developers
 
Replicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureReplicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureSalesforce Developers
 
Modern Development with Salesforce DX
Modern Development with Salesforce DXModern Development with Salesforce DX
Modern Development with Salesforce DXSalesforce Developers
 
Integrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectIntegrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectSalesforce Developers
 

Mais de Salesforce Developers (20)

Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce DevelopersSample Gallery: Reference Code and Best Practices for Salesforce Developers
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component PerformanceMaximizing Salesforce Lightning Experience and Lightning Component Performance
Maximizing Salesforce Lightning Experience and Lightning Component Performance
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base Components
 
TrailheaDX India : Developer Highlights
TrailheaDX India : Developer HighlightsTrailheaDX India : Developer Highlights
TrailheaDX India : Developer Highlights
 
Why developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX IndiaWhy developers shouldn’t miss TrailheaDX India
Why developers shouldn’t miss TrailheaDX India
 
CodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local DevelopmentCodeLive: Build Lightning Web Components faster with Local Development
CodeLive: Build Lightning Web Components faster with Local Development
 
CodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web ComponentsCodeLive: Converting Aura Components to Lightning Web Components
CodeLive: Converting Aura Components to Lightning Web Components
 
Enterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web ComponentsEnterprise-grade UI with open source Lightning Web Components
Enterprise-grade UI with open source Lightning Web Components
 
TrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer HighlightsTrailheaDX and Summer '19: Developer Highlights
TrailheaDX and Summer '19: Developer Highlights
 
Live coding with LWC
Live coding with LWCLive coding with LWC
Live coding with LWC
 
Lightning web components - Episode 4 : Security and Testing
Lightning web components  - Episode 4 : Security and TestingLightning web components  - Episode 4 : Security and Testing
Lightning web components - Episode 4 : Security and Testing
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura Interoperability
 
Lightning web components episode 2- work with salesforce data
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce data
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An Introduction
 
Migrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCPMigrating CPQ to Advanced Calculator and JSQCP
Migrating CPQ to Advanced Calculator and JSQCP
 
Scale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in SalesforceScale with Large Data Volumes and Big Objects in Salesforce
Scale with Large Data Volumes and Big Objects in Salesforce
 
Replicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data CaptureReplicate Salesforce Data in Real Time with Change Data Capture
Replicate Salesforce Data in Real Time with Change Data Capture
 
Modern Development with Salesforce DX
Modern Development with Salesforce DXModern Development with Salesforce DX
Modern Development with Salesforce DX
 
Get Into Lightning Flow Development
Get Into Lightning Flow DevelopmentGet Into Lightning Flow Development
Get Into Lightning Flow Development
 
Integrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS ConnectIntegrate CMS Content Into Lightning Communities with CMS Connect
Integrate CMS Content Into Lightning Communities with CMS Connect
 

Último

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 

Último (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 

Data Design Tips for Developing Robust Apps on Force.com

  • 1. Data Design Tips for Developing Robust Apps on Force.com Lessons learned while developing a finance system on Force.com Steven Lawrance, Salesforce.com, Lead Member of the Technical Staff
  • 2. Safe harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
  • 3. Steven Lawrance Lead Member of the Technical Staff
  • 4. Session Agenda ▪ Designing within limits ▪ Handing updates to arbitrary numbers of records ▪ Demonstration ▪ Executing aggregate queries with limits and offsets ▪ Sorting complex objects ▪ Q&A
  • 5. Designing within limits ▪ Design decisions should consider resource availability • Custom object limit • Custom tab limit • Storage limits • API call limits
  • 7. Designing within limits ▪ Scarce • Record storage ▪ Plentiful • Custom objects • Tabs • Apex code lines ▪ Selection of limits to optimize • Record storage limits were selected for optimization in this project. • Runtime computation was favored over temporary storage in a custom object.
  • 9. Handing updates to arbitrary numbers of records @future, Maps, and Visualforce are your friends. ▪ @future method: Asynchronously update batches of records. • Update only up to the DML execution and record limits. ▪ Maps: Identify batches in the keys and changes in the values. • @future private static void runLater(Map<String,String> batchUpdateValues) ▪ Visualforce: Use to re-invoke the next @future method call, if needed. • @future methods cannot be called from a @future method.
  • 10. Handing updates to arbitrary numbers of records Visualforce page sends groups of batches to the @future method ▪ Page checks the donation update status during the page load. • Updates required: Call the @future method and reload the page every 4 seconds. • Updates in progress: Reload the page every 4 seconds. • Complete: Display the regular user interface. ▪ The @future method updates donations until it gets to the DML limits. • Set the donation update status at the end of @future method.
  • 11. Handing updates to arbitrary numbers of records Processing within @future Input from Visualforce Key Value For each key, update each donation to the target value Credit Card AmEx 2013-11-02 Finance Batch a0nK0000000FAY 8 Credit Card AmEx 2013-11-02 Fred Smith AmEx 2013-11-02 $5.00 Finance Batch a0nK0000000FAY8 Alex Jones AmEx 2013-11-02 $10.00 Finance Batch a0nK0000000FAY8 Check 2013-11-02 B123456 . . . Finance Batch a0nK0000000FAY 9 . . . . . . Catherine Katz AmEx 2013-11-02 $10.00 . . .
  • 13. Executing aggregate queries with limits and offsets ▪ Aggregations can return at most 500 rows per query. ▪ By using LIMIT and OFFSET, it’s possible to query more than 500 aggregated rows. ▪ In an aggregate query, the OFFSET can’t be 2000 or higher.
  • 14. Executing aggregate queries with limits and offsets for (Integer batchOffset = 0; batchOffset < 2000;) { Integer aggregateBatchCount = 0, aggregateBatchSize = 500; for (AggregateResult donationBatch : [SELECT … FROM … WHERE … GROUP BY … ORDER BY … NULLS FIRST LIMIT :aggregateBatchSize OFFSET :batchOffset]) { aggregateBatchCount++; … } if (aggregateBatchCount < aggregateBatchSize) { break; } else { batchOffset += aggregateBatchCount; } }
  • 15. Executing aggregate queries with limits and offsets Break apart disjunctions into separate queries if it’s faster. ▪ If your query takes too long to execute and makes use of ‘OR’, then try splitting it into multiple queries that don’t use ‘OR’ SELECT … FROM Donation_Designation__c WHERE Donation__r.CloseDate >= :startDate AND Donation__r.CloseDate < :endDatePlusOne AND (Donation__r.Fin_Batch__r.Rec__c = :recId OR Donation__r.Batch__c = NULL OR Donation__r.Batch__r.Status__c = 'Committed') GROUP BY … ORDER BY … LIMIT … OFFSET …
  • 16. Executing aggregate queries with limits and offsets ▪ The query plan in the underlying database is much more efficient when all filters are conjunctive (joined with ‘AND’). SELECT … FROM Donation_Designation__c WHERE Donation__r.CloseDate >= :startDate AND Donation__r.CloseDate < :endDatePlusOne AND Donation__r.Fin_Batch__r.Rec__c = :recId GROUP BY … ORDER BY … LIMIT … OFFSET …
  • 17. Executing aggregate queries with limits and offsets ▪ Index range scans are faster than table scans. ▪ Use of ‘OR’ can lead to table scans. ▪ Salesforce.com can create an index for frequently filtered fields.
  • 18. Sorting complex objects ▪ Before Winter ‘14, using a Map<String,ComplexObject> and a List<String> to call List.sort() was a way to sort without running out of script statements. The properties exist in the String key in the order to sort by. ▪ In Winter ’14 and beyond, the recommended approach is to implement the Comparable interface and call List.sort() on a List of your object. • public class ComplexObject implements Comparable { … public Integer compareTo(Object compareTo) { /* implementation here */ } }
  • 19. Steven Lawrance Lead Member of the Technical Staff