function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Random Query Timeout Against Web API

We have 30 accounts with a fax provider. Every two hours we pull the faxes from the provider that arrived since the last run and insert them in to Salesforce.


They go in to a custom Fax object with meta-information fields like number of pages, caller id as a parent to an Attachment that is the actual fax. This is all done with a PHP script using the WEB API.


Step one is to locate the MAX reference number given to the fax by the vendor  for the given Fax account that Salesforce has seen last. Simple right?


SELECT Fax__c.VendorRefNumber__c FROM Fax__c  WHERE Fax__c.VendorAccount__c = '1234' ORDER BY Fax__c.VendorRefNumber__c LIMIT 1


This query has been running like a champ for over a year now. The query typically executes in < 200 ms. But for some reason since the last release there will be random times where it takes 30+ seconds and on occasion once or twice a day QUERY_TIMEOUT comes back.


Someone may be quick to say a governer limit has been reached cause over time the number of faxes has reached in to the thousands and too many records are being scanned. I would buy that if only someone could explain to me why it doesn't happen every time the query is issued.


Not only that but this script alerts me via email it has failed with a query timeout. I immediately jump on the box and kick the same PHP script off manually and the script runs right through all 30 accounts, each query taking less then 200 ms to complete.


I've provide a session id, uri, time, date and the exact query in a case but haven't heard anything productive back. Anyone here also know if I provide those items can someone on the support team go in an look at logs to determine exactly why the QUERY TIMEOUT was issue. Thus far my impression with TIER1 support is they cannot.








Reading around in forums and what not I'm starting to get the impression that the SOAP API calls are not reliable to the point that retry logic needs to be place around every API call. What I find fascinating if this is the case is that it fails much more than I would expect it to. And it has been getting worse over the last couple of years. One has to think are Salesforce computing resources starting to get stretched? Do these timeouts occur when at the very moment I'm doing a query someone else who happens to be on the same node is upserting a million rows? Ah the black box of Cloud computing.


I've just been through many calls, gotomeeting, and account managers to arrive at, empty the recycle bin, add filters (where clauses to the query) and potentially an index. But the indexes have to be custom added by Tier 3 support.


My questions are:

Has anyone done this with Salesforce before (you have to ask Tier 3 to add the index to the field)?

Does it cost money?

Has it become an issue each quarter when the version changes that it gets dropped?

Would I be better off writting to local disk where the injector program runs what the highest Fax_Reference_Number__c was for each Fax_Number so I don't have to run the query against salesforce at all?