+ Start a Discussion
SimplySfdcSimplySfdc 

QUERY_TIMEOUT

Hi,

I keep get "QUERY_TIMEOUT: Your query request was running for too long." when do query. Can anybody help....

sq
werewolfwerewolf
It is what it says: your query is running too long.  You're probably selecting too much data, or you are using a query with a bunch of ORs or complex conditions across a big data set.  Try to whittle it down to exactly the data you need.
SimplySfdcSimplySfdc
Hi,

My query is "select count() from asset", total records in asset is around 210,000 records.

sq
werewolfwerewolf
Well, I can see where that might cause a problem -- it is probably iterating over all your assets.  Is that what you really need then, a count of all your assets, or can you whittle it down some?
SimplySfdcSimplySfdc
Hi werewolf,

Actually what is my program do is delete all records from Asset and reload with new data everyday.
So, I do query "select id from asset" ---> this often keep error, but sometimes it works.
Then I use list of ID for deletion.
This program has work for 6+ mths with no issue, but last few weeks this errors occured more often.

sq
SuperfellSuperfell
because the of the delete + reload approach, the asset table is now dominated by deleted records, this will cause the kind of perf problems you are seeing. You should update your process to use the emptyRecycleBin call after calling delete, so that the deleted data can be quickly cleaned up, see http://www.salesforce.com/us/developer/docs/api/index_CSH.htm#sforce_api_calls_emptyrecyclebin.htm
SimplySfdcSimplySfdc
Hi Simon,

Seems like my issue is solved. emptyrecyclebin is available from version 10 and above, while my code is written using api version 9.
Thanks buddy.

sq
SimplySfdcSimplySfdc
Hi Simon,

I get error "invalid record id; no recycle bin entry found" when
call emptyRecycleBin, while the ID is available when I query
"Select Id from asset where isdeleted = true".

Why is this happen?

sq

SimplySfdcSimplySfdc
Hi Simon,

Just saw in APEX_API.PDF.
"After records are deleted from the recycle bin using this call, they can be queried using queryAll for some time.Typically this time is 24 hours, but may be shorter or longer."
Sorry for this. So, let me check again tomorrow morning.

cheers.
sq
PannarPannar

Hi Simon/werwolf.

even i am getting the QUERY_TIMEOUT exception when i tried to fetch the contact records from SFDC. There is not much deleted records available in recyclebin.

Code:
Select c.AccountId, c.Account.Id, c.Account.Name, 
c.Account.acc_Id__c, c.Account.tfcmCustomerMasterId__c, 
c.Account.tocCMAddressId__c, c.DoNotCall, c.Email, 
c.FirstName, c.HasOptedOutOfEmail, c.Id, c.LastName, 
c.MailingCity, c.MailingCountry, c.MailingPostalCode, 
c.MailingState, c.MailingStreet, c.MobilePhone, c.Name, 
c.OwnerId, c.Owner.Email, c.Owner.EmployeeNumber, 
c.Owner.FirstName, c.Owner.Id, c.Owner.LastName, 
c.Owner.Name, c.Phone, c.tfContactCategory__c, c.Title, 
c.tocContactStatus__c, c.tocContactId__c,c.Salutation, 
c.tocAssetFocus__c, c.tocDirectMarketing__c, 
c.tocEndUserActivity__c, c.tocFloor__c, 
c.tocFunction__c, c.Department, c.tocLanguage__c, 
c.tocLegalConsent__c, c.tocLocalCity__c, c.tocLocalCountry__c, 
c.tocLocalFirstName__c, c.tocLocalLastName__c, 
c.tocLocalPostal__c, c.tocLocalSalutation__c, c.tocLocalState__c, 
c.tocLocalStreet__c, c.CreatedById, c.CreatedDate, 
c.LastModifiedById, c.LastModifiedDate from Contact c 
where c.tocContactId__c<>null

 can we extend the time somewhere in sfdc?
please advice.
BrandiTBrandiT

I had this same problem.  We delete all records in a custom object every day and load new records.  I tried deleting my org's recycle bin and still couldn't get it to work.

 

I finally figured out to apply a filter to my query:  Isdeleted=false

 

This has fixed the problem for me.  Just thought I'd post in case anyone else is getting this error  :)

RaguRagu

Thought this might be useful to somebody,


Use limit keyword in your query. It will solve your problem. I solved my issue by just adding limit as 2000000 though my sf object has 900000 records.