SlideShare a Scribd company logo
1 of 20
Creative way of coding
Jean-Luc Antoine, @ApexAPI, May 2017
Think out of the box for more
efficient Salesforce
administration
Paris Salesforce Developer Group
1
Use Case
• As a Salesforce administrator, I want to identify the fields that
have not been used since a long time.
• My object is
- hosting millions of records
- heavily customized
• I want to do this for multiple objects
2
Constraints
• I need to
- Optimize the network
I don’t want to download gigabytes of data over the network
- Optimize the API
I have limited calls per 24h
- Automate the process
I will not do this manually, it has to be automated
- Optimize duration
I should not wait too much to get the information
3
Quick facts
• Large Date Volume orgs are difficult to query
- Timeouts can occur frequently
- Can hit the limit of long running queries
• The way you are using the API can impact perf
- HTTP1.1 / keepAlive
- Gzip compression
This is out of scope of this study
4
Use case - reducing the scope
• We will not analyze
- Formula fields
- Non nilable fields (checked as required)
- Checkboxes (true or false, no capability to identify if it has been set)
- System fields
• We must configure
- The Date field to be used
CreatedDate or LastModifiedDate? Impact on migration on those fields?
5
Solution 1 – download + process
• Use any tool such as Dataloader
• Parse locally the resulting CSV file
• Impacts
+ Moderate API usage
-- Long time to prepare the file on server side
-- Long time to download the file
-- Downloading everything even if the first records tells you all fields are
used.
Waste of resource and time.
6
Solution 1 – duration
7
Duration
API usage
Solution 1
Network usage
Solution 1
End of
processing 1
Qty
•Run the query
•Prepare the resulting file
for download
•Api calls to identify when
it is ready for download
Download
Local
processing
•Not efficient if all
the fields have been
recently used as we
still download
everything
Solution 2 – API + continuous process
• Use the API to run your query
• Do a queryMore() until you find the last used date for all fields
- You receive your records in bulk of BatchSize
- The more you query fields, the smaller your BatchSize is
50 fields can drive to a batchsize of 200 while 3 fields can give you 2000 records in a
batch
• Impacts
+ Optimizing the number of records retrieved as you can stop the process as
soon as you have the information for all your fields
-- Lots of API consumption (small batch size, huge number of records)
-- Long duration because lots of API round trips + long initial query
8
Solution 2 - duration
9
Duration
API usage Solution 2
Network usage Solution 2
End of
processing 2
Qty
Server time
before first
result
N x
(processing +
queryMore())
•Can have timeouts
•Slow when all fields
have been recently
used
•Not efficient for the
last fields to be found
as we retrieve all
fields
Solutions - duration
10
Duration
API usage Solution 2
Network usage Solution 2API usage
Solution 1
Network usage
Solution 1
End of
processing 1
End of
processing 2
Qty
Solution 3 – refined query
• Use the API to run your query
• Do a queryMore() until you find the last used date for all fields, or
do a new query() with less fields if you found some fields
- The BatchSize will increase progressively
The quantity of records per roundtrip will increase
The total duration will decrease compared to Solution 2
• Impacts
+ Optimizing the number of records retrieved as you can stop the process as
soon as you have the information for all your fields
+ Less API calls than Solution 2
+ Quicker compared to Solution 2 as you increase the throughput
-- Still long initial query, and some when refining the query
11
Solution 3 - duration
12
Duration
API usage Solution 3
Network usage Solution 3
End of
processing 3
Qty
•Multiple queries that
are progressively faster
•Accelerating throughput,
reducing the time
Solutions - duration
13
Duration
API usage Solution 2
Network usage Solution 2API usage
Solution 1
Network usage
Solution 1
End of
processing 1
End of
processing 2
Qty
API 3
Network 3
End 3
Solution 4 – server processing
• Same query optimization as Solution 3
• Executed as ApexAnonymous on the Server
• Impacts
+ Capability to process much more records in 1 roundtrip
Theorically up to 50k, but limited to CPU time less than 10k
+ Immediate query because of the “limit 10k”
No need to wait for the snapshot on the DB server
+ Optimized network
Only results are transmitted, not the data
+ Optimized API
Because of the huge batch size
14
Technical tip to develop Solution 4
• Use ApexAnonymous
- No need to deploy/inject anything in the org
- executeanonymous() from SOAP API
Very efficient, retrieve Apex debug logs as the result
- executeAnonymous using the tooling API
Requires lots of API calls
1. POST to /tooling/sobjects/traceFlag to define the debug log level
2. Execute the anonymous Apex code
3. Get the Id of the last log from the ApexLog tooling object
4. retrieve the debug log content by querying the ApexLog object Body
15
Technical tip to develop Solution 4
• How to get the result of Apex processing on client side?
- The Apex Code needs to prepare a JSON dump using system.debug()
- The client need to retrieve the debug logs, filter the custom debug
statements to regenerate the JSON, then use it
• Apex Code is dynamically autogenerated to have the progressive
query enhancement
- Removing progressively from the query the fields that have been found
16
Solution 4 - duration
17
Duration
API usage
Solution 4
Network usage
Solution 4
End of
processing 4
Qty
•Immediate query
performance
•No timeout •Accelerating throughput,
reducing the time
Solutions - duration
18
Duration
API usage Solution 2
Network usage Solution 2
API 1
Network usage
Solution 1
End of
processing 1
End of
processing 2
Qty
API 3
Network 3
End 3
End 4
Net4
API 4
Code
• Available to run directly on AdminBooster Salesforce Playground
• Solution 3
https://www.adminbooster.com/tool#listing=ajaxlastused
• Solution 4
https://www.adminbooster.com/tool#listing=ajaxlastusedapex
19
Q&A

More Related Content

What's hot

How_To_Soup_Up_Your_Farm
How_To_Soup_Up_Your_FarmHow_To_Soup_Up_Your_Farm
How_To_Soup_Up_Your_Farm
Nigel Price
 
What is App Engine? O
What is App Engine? OWhat is App Engine? O
What is App Engine? O
ikailan
 
Using Oracle Database with Amazon Web Services
Using Oracle Database with Amazon Web ServicesUsing Oracle Database with Amazon Web Services
Using Oracle Database with Amazon Web Services
guest484c12
 

What's hot (20)

ECS19 - Ingo Gegenwarth - Running Exchange in large environment
ECS19 - Ingo Gegenwarth -  Running Exchangein large environmentECS19 - Ingo Gegenwarth -  Running Exchangein large environment
ECS19 - Ingo Gegenwarth - Running Exchange in large environment
 
SharePoint 2010 Boost your farm performance!
SharePoint 2010 Boost your farm performance!SharePoint 2010 Boost your farm performance!
SharePoint 2010 Boost your farm performance!
 
Scaling wix with microservices and multi cloud - 2015
Scaling wix with microservices and multi cloud - 2015Scaling wix with microservices and multi cloud - 2015
Scaling wix with microservices and multi cloud - 2015
 
Microsoft SQL Server Query Tuning
Microsoft SQL Server Query TuningMicrosoft SQL Server Query Tuning
Microsoft SQL Server Query Tuning
 
How_To_Soup_Up_Your_Farm
How_To_Soup_Up_Your_FarmHow_To_Soup_Up_Your_Farm
How_To_Soup_Up_Your_Farm
 
Building Web APIs that Scale
Building Web APIs that ScaleBuilding Web APIs that Scale
Building Web APIs that Scale
 
Building a Scalable Architecture for web apps
Building a Scalable Architecture for web appsBuilding a Scalable Architecture for web apps
Building a Scalable Architecture for web apps
 
Developing a provider hosted share point app
Developing a provider hosted share point appDeveloping a provider hosted share point app
Developing a provider hosted share point app
 
Migrating Data and Databases to Azure
Migrating Data and Databases to AzureMigrating Data and Databases to Azure
Migrating Data and Databases to Azure
 
(ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service (ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service
 
SharePoint Topology
SharePoint Topology SharePoint Topology
SharePoint Topology
 
NOMAD ENTERPRISE & WAN CACHING APPLIANCES NETWORK OPTIMIZATION IN A CONFIGURA...
NOMAD ENTERPRISE & WAN CACHING APPLIANCES NETWORK OPTIMIZATION IN A CONFIGURA...NOMAD ENTERPRISE & WAN CACHING APPLIANCES NETWORK OPTIMIZATION IN A CONFIGURA...
NOMAD ENTERPRISE & WAN CACHING APPLIANCES NETWORK OPTIMIZATION IN A CONFIGURA...
 
Application Scalability in Server Farms - NCache
Application Scalability in Server Farms - NCacheApplication Scalability in Server Farms - NCache
Application Scalability in Server Farms - NCache
 
From Obvious to Ingenius: Incrementally Scaling Web Apps on PostgreSQL
From Obvious to Ingenius: Incrementally Scaling Web Apps on PostgreSQLFrom Obvious to Ingenius: Incrementally Scaling Web Apps on PostgreSQL
From Obvious to Ingenius: Incrementally Scaling Web Apps on PostgreSQL
 
What is App Engine? O
What is App Engine? OWhat is App Engine? O
What is App Engine? O
 
Database Core performance principles
Database Core performance principlesDatabase Core performance principles
Database Core performance principles
 
Using Oracle Database with Amazon Web Services
Using Oracle Database with Amazon Web ServicesUsing Oracle Database with Amazon Web Services
Using Oracle Database with Amazon Web Services
 
Redis vs NCache - A detailed feture level comparison
Redis vs NCache - A detailed feture level comparisonRedis vs NCache - A detailed feture level comparison
Redis vs NCache - A detailed feture level comparison
 
Scalable Web Architecture and Distributed Systems
Scalable Web Architecture and Distributed SystemsScalable Web Architecture and Distributed Systems
Scalable Web Architecture and Distributed Systems
 
Making (Almost) Any Database Faster and Cheaper with Caching
Making (Almost) Any Database Faster and Cheaper with CachingMaking (Almost) Any Database Faster and Cheaper with Caching
Making (Almost) Any Database Faster and Cheaper with Caching
 

Similar to Pratiques administration avancées et techniques de développement

Metrics-driven tuning of Apache Spark at scale
Metrics-driven tuning of Apache Spark at scaleMetrics-driven tuning of Apache Spark at scale
Metrics-driven tuning of Apache Spark at scale
DataWorks Summit
 
Secrets of highly_avail_oltp_archs
Secrets of highly_avail_oltp_archsSecrets of highly_avail_oltp_archs
Secrets of highly_avail_oltp_archs
Tarik Essawi
 
Automate Studio Training: Materials Maintenance Tips for Efficiency and Ease ...
Automate Studio Training: Materials Maintenance Tips for Efficiency and Ease ...Automate Studio Training: Materials Maintenance Tips for Efficiency and Ease ...
Automate Studio Training: Materials Maintenance Tips for Efficiency and Ease ...
Precisely
 

Similar to Pratiques administration avancées et techniques de développement (20)

Silicon Valley Code Camp 2014 - Advanced MongoDB
Silicon Valley Code Camp 2014 - Advanced MongoDBSilicon Valley Code Camp 2014 - Advanced MongoDB
Silicon Valley Code Camp 2014 - Advanced MongoDB
 
Paris.rb – 07/19 – Sidekiq scaling, workers vs processes
Paris.rb – 07/19 – Sidekiq scaling, workers vs processesParis.rb – 07/19 – Sidekiq scaling, workers vs processes
Paris.rb – 07/19 – Sidekiq scaling, workers vs processes
 
Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016
 
PyData London 2017 – Efficient and portable DataFrame storage with Apache Par...
PyData London 2017 – Efficient and portable DataFrame storage with Apache Par...PyData London 2017 – Efficient and portable DataFrame storage with Apache Par...
PyData London 2017 – Efficient and portable DataFrame storage with Apache Par...
 
Internals of Presto Service
Internals of Presto ServiceInternals of Presto Service
Internals of Presto Service
 
Hardware Provisioning
Hardware ProvisioningHardware Provisioning
Hardware Provisioning
 
Presto meetup 2015-03-19 @Facebook
Presto meetup 2015-03-19 @FacebookPresto meetup 2015-03-19 @Facebook
Presto meetup 2015-03-19 @Facebook
 
Realtime traffic analyser
Realtime traffic analyserRealtime traffic analyser
Realtime traffic analyser
 
Big Data for QAs
Big Data for QAsBig Data for QAs
Big Data for QAs
 
Metrics-driven tuning of Apache Spark at scale
Metrics-driven tuning of Apache Spark at scaleMetrics-driven tuning of Apache Spark at scale
Metrics-driven tuning of Apache Spark at scale
 
Secrets of highly_avail_oltp_archs
Secrets of highly_avail_oltp_archsSecrets of highly_avail_oltp_archs
Secrets of highly_avail_oltp_archs
 
Automate Studio Training: Materials Maintenance Tips for Efficiency and Ease ...
Automate Studio Training: Materials Maintenance Tips for Efficiency and Ease ...Automate Studio Training: Materials Maintenance Tips for Efficiency and Ease ...
Automate Studio Training: Materials Maintenance Tips for Efficiency and Ease ...
 
Lessons Learned Replatforming A Large Machine Learning Application To Apache ...
Lessons Learned Replatforming A Large Machine Learning Application To Apache ...Lessons Learned Replatforming A Large Machine Learning Application To Apache ...
Lessons Learned Replatforming A Large Machine Learning Application To Apache ...
 
(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool Management(ATS4-PLAT08) Server Pool Management
(ATS4-PLAT08) Server Pool Management
 
(ATS6-PLAT06) Maximizing AEP Performance
(ATS6-PLAT06) Maximizing AEP Performance(ATS6-PLAT06) Maximizing AEP Performance
(ATS6-PLAT06) Maximizing AEP Performance
 
Monitorama 2015 Netflix Instance Analysis
Monitorama 2015 Netflix Instance AnalysisMonitorama 2015 Netflix Instance Analysis
Monitorama 2015 Netflix Instance Analysis
 
Benchmarking at Parse
Benchmarking at ParseBenchmarking at Parse
Benchmarking at Parse
 
Advanced Benchmarking at Parse
Advanced Benchmarking at ParseAdvanced Benchmarking at Parse
Advanced Benchmarking at Parse
 
REST Api Tips and Tricks
REST Api Tips and TricksREST Api Tips and Tricks
REST Api Tips and Tricks
 
Building Awesome APIs with Lumen
Building Awesome APIs with LumenBuilding Awesome APIs with Lumen
Building Awesome APIs with Lumen
 

More from Paris Salesforce Developer Group

More from Paris Salesforce Developer Group (18)

Pour Noël, devenez chrome extensioniste!
Pour Noël, devenez chrome extensioniste!Pour Noël, devenez chrome extensioniste!
Pour Noël, devenez chrome extensioniste!
 
GraphQL (la nouvelle API de référence de Salesforce ?!)
GraphQL (la nouvelle API de référence de Salesforce ?!)GraphQL (la nouvelle API de référence de Salesforce ?!)
GraphQL (la nouvelle API de référence de Salesforce ?!)
 
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
La Tooling API, est-ce pour moi ? Bien sûr, viens voir pourquoi !
 
Introduction à la plateforme Anypoint de MuleSoft
Introduction à la plateforme Anypoint de MuleSoftIntroduction à la plateforme Anypoint de MuleSoft
Introduction à la plateforme Anypoint de MuleSoft
 
Release spring '22 - Community Groups français
Release spring '22 - Community Groups françaisRelease spring '22 - Community Groups français
Release spring '22 - Community Groups français
 
Scratch orgs...vous pensiez en avoir terminé avec les sandboxes ?
Scratch orgs...vous pensiez en avoir terminé avec les sandboxes ?Scratch orgs...vous pensiez en avoir terminé avec les sandboxes ?
Scratch orgs...vous pensiez en avoir terminé avec les sandboxes ?
 
Mon Expérience avec le Certified Technical Architect Review Board
 Mon Expérience avec le Certified Technical Architect Review Board Mon Expérience avec le Certified Technical Architect Review Board
Mon Expérience avec le Certified Technical Architect Review Board
 
Mieux acheminer les emails avec salesforce
Mieux acheminer les emails avec salesforceMieux acheminer les emails avec salesforce
Mieux acheminer les emails avec salesforce
 
DX@Scale: Optimizing Salesforce Development and Deployment for large scale pr...
DX@Scale: Optimizing Salesforce Development and Deployment for large scale pr...DX@Scale: Optimizing Salesforce Development and Deployment for large scale pr...
DX@Scale: Optimizing Salesforce Development and Deployment for large scale pr...
 
Dreamforce Global Gathering
Dreamforce Global GatheringDreamforce Global Gathering
Dreamforce Global Gathering
 
Getting started with Salesforce DX
Getting started with Salesforce DXGetting started with Salesforce DX
Getting started with Salesforce DX
 
Sensibilisation à la Sécurité Salesforce
Sensibilisation à la Sécurité SalesforceSensibilisation à la Sécurité Salesforce
Sensibilisation à la Sécurité Salesforce
 
Introducing salesforce shield - Paris Salesforce Developer Group - Oct 15
Introducing salesforce shield - Paris Salesforce Developer Group - Oct 15Introducing salesforce shield - Paris Salesforce Developer Group - Oct 15
Introducing salesforce shield - Paris Salesforce Developer Group - Oct 15
 
Meetup 06/2015 - @testsetup
Meetup 06/2015 - @testsetupMeetup 06/2015 - @testsetup
Meetup 06/2015 - @testsetup
 
Meetup Custom Metadata - 1st Part
Meetup Custom Metadata - 1st PartMeetup Custom Metadata - 1st Part
Meetup Custom Metadata - 1st Part
 
Lightning week - Paris DUG
Lightning week - Paris DUGLightning week - Paris DUG
Lightning week - Paris DUG
 
Versionning et travail en équipe avec Salesforce - 27/11/2014
Versionning et travail en équipe avec Salesforce - 27/11/2014Versionning et travail en équipe avec Salesforce - 27/11/2014
Versionning et travail en équipe avec Salesforce - 27/11/2014
 
Paris Salesforce Developer Group - 16 09 2014 - Summer '14
Paris Salesforce Developer Group - 16 09 2014 - Summer '14Paris Salesforce Developer Group - 16 09 2014 - Summer '14
Paris Salesforce Developer Group - 16 09 2014 - Summer '14
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Pratiques administration avancées et techniques de développement

  • 1. Creative way of coding Jean-Luc Antoine, @ApexAPI, May 2017 Think out of the box for more efficient Salesforce administration Paris Salesforce Developer Group 1
  • 2. Use Case • As a Salesforce administrator, I want to identify the fields that have not been used since a long time. • My object is - hosting millions of records - heavily customized • I want to do this for multiple objects 2
  • 3. Constraints • I need to - Optimize the network I don’t want to download gigabytes of data over the network - Optimize the API I have limited calls per 24h - Automate the process I will not do this manually, it has to be automated - Optimize duration I should not wait too much to get the information 3
  • 4. Quick facts • Large Date Volume orgs are difficult to query - Timeouts can occur frequently - Can hit the limit of long running queries • The way you are using the API can impact perf - HTTP1.1 / keepAlive - Gzip compression This is out of scope of this study 4
  • 5. Use case - reducing the scope • We will not analyze - Formula fields - Non nilable fields (checked as required) - Checkboxes (true or false, no capability to identify if it has been set) - System fields • We must configure - The Date field to be used CreatedDate or LastModifiedDate? Impact on migration on those fields? 5
  • 6. Solution 1 – download + process • Use any tool such as Dataloader • Parse locally the resulting CSV file • Impacts + Moderate API usage -- Long time to prepare the file on server side -- Long time to download the file -- Downloading everything even if the first records tells you all fields are used. Waste of resource and time. 6
  • 7. Solution 1 – duration 7 Duration API usage Solution 1 Network usage Solution 1 End of processing 1 Qty •Run the query •Prepare the resulting file for download •Api calls to identify when it is ready for download Download Local processing •Not efficient if all the fields have been recently used as we still download everything
  • 8. Solution 2 – API + continuous process • Use the API to run your query • Do a queryMore() until you find the last used date for all fields - You receive your records in bulk of BatchSize - The more you query fields, the smaller your BatchSize is 50 fields can drive to a batchsize of 200 while 3 fields can give you 2000 records in a batch • Impacts + Optimizing the number of records retrieved as you can stop the process as soon as you have the information for all your fields -- Lots of API consumption (small batch size, huge number of records) -- Long duration because lots of API round trips + long initial query 8
  • 9. Solution 2 - duration 9 Duration API usage Solution 2 Network usage Solution 2 End of processing 2 Qty Server time before first result N x (processing + queryMore()) •Can have timeouts •Slow when all fields have been recently used •Not efficient for the last fields to be found as we retrieve all fields
  • 10. Solutions - duration 10 Duration API usage Solution 2 Network usage Solution 2API usage Solution 1 Network usage Solution 1 End of processing 1 End of processing 2 Qty
  • 11. Solution 3 – refined query • Use the API to run your query • Do a queryMore() until you find the last used date for all fields, or do a new query() with less fields if you found some fields - The BatchSize will increase progressively The quantity of records per roundtrip will increase The total duration will decrease compared to Solution 2 • Impacts + Optimizing the number of records retrieved as you can stop the process as soon as you have the information for all your fields + Less API calls than Solution 2 + Quicker compared to Solution 2 as you increase the throughput -- Still long initial query, and some when refining the query 11
  • 12. Solution 3 - duration 12 Duration API usage Solution 3 Network usage Solution 3 End of processing 3 Qty •Multiple queries that are progressively faster •Accelerating throughput, reducing the time
  • 13. Solutions - duration 13 Duration API usage Solution 2 Network usage Solution 2API usage Solution 1 Network usage Solution 1 End of processing 1 End of processing 2 Qty API 3 Network 3 End 3
  • 14. Solution 4 – server processing • Same query optimization as Solution 3 • Executed as ApexAnonymous on the Server • Impacts + Capability to process much more records in 1 roundtrip Theorically up to 50k, but limited to CPU time less than 10k + Immediate query because of the “limit 10k” No need to wait for the snapshot on the DB server + Optimized network Only results are transmitted, not the data + Optimized API Because of the huge batch size 14
  • 15. Technical tip to develop Solution 4 • Use ApexAnonymous - No need to deploy/inject anything in the org - executeanonymous() from SOAP API Very efficient, retrieve Apex debug logs as the result - executeAnonymous using the tooling API Requires lots of API calls 1. POST to /tooling/sobjects/traceFlag to define the debug log level 2. Execute the anonymous Apex code 3. Get the Id of the last log from the ApexLog tooling object 4. retrieve the debug log content by querying the ApexLog object Body 15
  • 16. Technical tip to develop Solution 4 • How to get the result of Apex processing on client side? - The Apex Code needs to prepare a JSON dump using system.debug() - The client need to retrieve the debug logs, filter the custom debug statements to regenerate the JSON, then use it • Apex Code is dynamically autogenerated to have the progressive query enhancement - Removing progressively from the query the fields that have been found 16
  • 17. Solution 4 - duration 17 Duration API usage Solution 4 Network usage Solution 4 End of processing 4 Qty •Immediate query performance •No timeout •Accelerating throughput, reducing the time
  • 18. Solutions - duration 18 Duration API usage Solution 2 Network usage Solution 2 API 1 Network usage Solution 1 End of processing 1 End of processing 2 Qty API 3 Network 3 End 3 End 4 Net4 API 4
  • 19. Code • Available to run directly on AdminBooster Salesforce Playground • Solution 3 https://www.adminbooster.com/tool#listing=ajaxlastused • Solution 4 https://www.adminbooster.com/tool#listing=ajaxlastusedapex 19
  • 20. Q&A