この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

Newer Version Available

This content describes an older version of this product. View Latest

null 値検索の回避によるパフォーマンスの改善

SOQL クエリおよび SOSL クエリで、null 値を含むレコードの検索を回避します。パフォーマンスを改善するために、まず null 値を除外します。次の例では、treadID の値が null であるすべてのレコードが返される値から除外されます。
1Public class TagWS {
2
3/* getThreadTags
4*
5* a quick method to pull tags not in the existing list
6*
7*/
8public static webservice List<String> 
9       getThreadTags(String threadId, List<String> tags) {
10   system.debug(LoggingLevel.Debug,tags);
11
12   List<String> retVals = new List<String>();
13   Set<String> tagSet = new Set<String>();
14   Set<String> origTagSet = new Set<String>();
15   origTagSet.addAll(tags);
16
17// Note WHERE clause verifies that threadId is not null
18
19   for(CSO_CaseThread_Tag__c t : 
20      [SELECT Name FROM CSO_CaseThread_Tag__c 
21      WHERE Thread__c = :threadId AND
22      threadID != null]) 
23
24{
25   tagSet.add(t.Name);
26}
27   for(String x : origTagSet) { 
28   // return a minus version of it so the UI knows to clear it
29      if(!tagSet.contains(x)) retVals.add('-' + x);
30}
31   for(String x : tagSet) { 
32   // return a plus version so the UI knows it's new
33      if(!origTagSet.contains(x)) retvals.add('+' + x);
34}
35
36   return retVals;
37}