question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hitting result max when using too many query selectors

See original GitHub issue

I’m running into an issue where a max of only 200 records are returned if several query selectors are being used. This is an issue for me since I’m selecting all attributes on the corresponding model within the ORM so that I don’t get back every field from salesforce. The issue can be reproduced by using the all selector '*'. For example, assuming the Account object has 450 records:

// This query will return all 450 records.
conn.sobject('Account')
  .select('Id')
  .execute(function(err, res) {
    console.log('LEN: ' + res.length)
  })

// However, this query will only return 200 records
conn.sobject('Account')
  .select('*')
  .execute(function(err, res) {
    console.log('LEN: ' + res.length)
  })

I’ve ran the query directly against SFDC API using all of the model attributes and it returns all records for me so something may be causing this issue within jsforce. I also checked on what lib/connection.js is sending to the API and it seems to build the HTTP request just fine. It’s possible that something is up with the post processing of the response body but I’m not entirely sure.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
stomitacommented, Jul 1, 2014

To fetch all records automatically, you can use autoFetch option in query execution. In this case you should listen “record” event to manipulate returning records.

var records = [];
conn.sobject("Account").select("Id,Name").execute({ autoFetch : true, maxFetch : 4000 })
  .on("record", function(record) {
    records.push(record);
  })
  .on("end", function(query) {
    console.log("total in database : " + query.totalSize);
    console.log("total fetched : " + query.totalFetched);
  })
  .on("error", function(err) {
    console.error(err);
  });
3reactions
mcbergsmacommented, Nov 28, 2019

I just ran into this issue as well using the event driven style. I tried @turakvlad 's suggestion of appending ,'*' to my find, but it didn’t work. I couldn’t find any documentation on how to implement it, but it turns out this works.

req.conn.sobject('customObj')
  .find({stuff})
  .autoFetch(true)
  .maxFetch(100000)
  .execute((err, results) => .... )

I don’t have more than 10K records to fetch, but setting maxFetch alone to a large number didn’t make any difference, removing it and only using autoFetch was enough for my needs, but I added the maxFetch option anyway for a bit of future-proofing since I assume it will default to 10K.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Paginate search results | Elasticsearch Guide [8.5] | Elastic
Avoid using from and size to page too deeply or request too many results at once. Search requests usually span multiple shards.
Read more >
Defining CSS media queries within selectors - Stack Overflow
Short answer, no. There are no performance issues in defining media queries within CSS selectors. But let's dive in.
Read more >
Avoid an excessive DOM size - Chrome Developers
A large DOM tree can slow down your page performance in multiple ways: Network efficiency and load performance.
Read more >
Beginner's guide to media queries - Learn web development
In practice, using minimum or maximum values is much more useful for responsive design so you will rarely see width or height used...
Read more >
Grouping Information in Results - Vespa Documentation
In many scenarios, a large collection of groups is produced, possibly too large to ... Use max(inf) to retrieve all hits when the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found