Snowfakery icon indicating copy to clipboard operation
Snowfakery copied to clipboard

query caching / reduce API usage

Open JonnyPower opened this issue 3 years ago • 1 comments
trafficstars

I've noticed huge API usage with some of my recipes. I suspect it's because of my usage of find_record (I have a few in my recipe, and I repeat my recipe for many iterations)

After a brief look at the standard plugin, I see we are just hitting simple_salesforce and running the query.

Would it be worthwhile to assume an identical query ran as a repetition for the same task could be configured to put/read from a cache instead of hitting the API?

For my use case, these records already exist in the org, are not be mutated by my recipes - and the queries return the exact same result every time.

If this is something others think is worthwhile I'll open a PR.

Would likely want it to be configured / disabled by default though as I'm sure others are relying on the realtime / accurate behaviour of the find_record method as it is today.

JonnyPower avatar Jan 27 '22 08:01 JonnyPower

Hello @jonnypower, cool to see Traction is using Snowfakery. I'm from Vancity myself.

I wonder if this solution would let you address the issue without changing Snowfakery itself:

- var: User1
  value:
    SalesforceQuery.random_record:
      from: User
      fields: Id, FirstName, LastName

https://github.com/SFDO-Tooling/Snowfakery/blob/f7e085e0d8f1b41a2ad38b3dbe5c672c2effbea5/examples/salesforce_soql_example.recipe.yml#L18

prescod avatar Jan 28 '22 00:01 prescod