Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize hydrating/retrieving data by using SOQL functions as much as possible #18

Closed
d416 opened this issue Apr 1, 2023 · 2 comments
Closed
Labels
enhancement New feature or request

Comments

@d416
Copy link

d416 commented Apr 1, 2023

Is your feature request related to a problem? Please describe.
SOQL should be used as much as possible for executing data functions before retrieving.

Describe the solution you'd like
A couple of examples...

EXAMPLE 1:
select count(*) from salesforce_opportunity

^ this query will
a) download all records from salesforce_opportunity
b) perform a SQL count() on the data in postgres

It works for a few hundred records maybe, but for data sets of thousands this takes quite awhile. SOQL has its own count() function, so why not use that and let Salesforce carry the load?

EXAMPLE 2:

select id, createddate from salesforce_account limit 10

^ this query will retrieve the first 10 records from the Account object and runs relatively quickly.

but...

select id, createddate from account order by createddate desc limit 10

^ this query will download all records from the Account object then sort them in Postgres by createddate, then return the first 10 records which can take quite awhile.
Salesforce has its own 'order by' function - why not use it and let Salesforce do the lifting here?

Describe alternatives you've considered
Waiting for real simple queries like the above to execute, or even time-out if large data is present in Salesforce.

@d416 d416 added the enhancement New feature or request label Apr 1, 2023
@d416
Copy link
Author

d416 commented Apr 2, 2023

Many Salesforce connectors/libraries use parsers, such as mulesoft's hardened code:
https://github.com/adam84luong/salesforce-soql-parser/blob/master/src/main/antlr3/org/mule/tools/soql/parser/SOQL.g

Here is a similar one in golang...
https://github.com/tzmfreedom/soql-parser/blob/master/parser/soql_parser.go

...but then perhaps we're just bound by what simpleforce can do and this is an issue for that code base

@cbruno10
Copy link
Contributor

cbruno10 commented Jul 6, 2023

@d416 Thanks for opening this issue!

At the moment, for queries like the one you shared above, we don't get any order by information from queries, so unfortunately we wouldn't be able to use that information to affect how we form the SOQL and make API calls.

I've opened turbot/steampipe-plugin-sdk#596 for tracking, which would enable us to do so.

I'm closing this issue in the meantime as the feature is not available, but if there are additional use cases outside of order by, please feel free to re-open!

@cbruno10 cbruno10 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants