You need to sign in to do that
Don't have an account?
YiQin He
Query efficiency issue with User object
Hi
Recently, I have a issue that bugging me for several weeks. We have a email system that uses a custom object for saving emails. The total data amount is alreay around 1M and each of the user has an average of 10K records. When user login, we show the email page and by default we display 10 email records on the page. My query was originally using OwnerId as criteria to filter in user's records and it takes so long to get the reponse back and sometime get a transaction timeout error. Yesterday, I changed the criteria to use Owner.Email and this time it's improving drastically! (with only 10 secs) So I am really confused about the result. Does anyone has idea on this?
Recently, I have a issue that bugging me for several weeks. We have a email system that uses a custom object for saving emails. The total data amount is alreay around 1M and each of the user has an average of 10K records. When user login, we show the email page and by default we display 10 email records on the page. My query was originally using OwnerId as criteria to filter in user's records and it takes so long to get the reponse back and sometime get a transaction timeout error. Yesterday, I changed the criteria to use Owner.Email and this time it's improving drastically! (with only 10 secs) So I am really confused about the result. Does anyone has idea on this?
SELECT Id, Subject__c, CreatedDate
FROM Email__c
WHERE OwnerId = UserInfo.GetUserId();
ORDER BY CreatedDate DESC LIMIT 10
this is running so slow that sometimes I will get 'No response from the server' error.
Now I changed it to:
SELECT Id, Subject__c, CreatedDate
FROM Email__c
WHERE Owner.Email = UserInfo.GetEmail();
ORDER BY CreatedDate DESC LIMIT 10
and this is working great.
So I'm very confused, why using email runs faster than using Id