• Dennis Antle
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
I have two metadata tables meta1, meta2 that have a Parent-child relationship labeled metarelate.
In meta2 the column Type__c is a Picklist.
Below are 2 different methods for querying the metadata tables.
Query 1
String metatype = 'type1';
for(meta1 m : [SELECT Persona__c, metarelate__r.Name__c   from meta1 
                                                            WHERE metarelate__r.Active__c = true 
                                                            and metarelate__r.Type__c = :metatype]){
       //does not loop through any rows.
}
but If I do this
Query 2
String metatype = 'type1';
for(meta1 m : [SELECT Persona__c, metarelate__r.Name__c, metarelate__r.Type__c   from meta1 
                                                            WHERE metarelate__r.Active__c = true]){ 
       if(m.metarelate__r.Type__c = metatype){
                //does loop through rows that have Type__c = 'type1'.
       }
}
 The query has alot of records, so I want to do it the first way, to save on CPU Time. But it will only work the second way, which eats up CPU Time. Why is it that in Query1 the where Clause on Type__c Column is not working. FYI it's a picklist.
 
I have two metadata tables meta1, meta2 that have a Parent-child relationship labeled metarelate.
In meta2 the column Type__c is a Picklist.
Below are 2 different methods for querying the metadata tables.
Query 1
String metatype = 'type1';
for(meta1 m : [SELECT Persona__c, metarelate__r.Name__c   from meta1 
                                                            WHERE metarelate__r.Active__c = true 
                                                            and metarelate__r.Type__c = :metatype]){
       //does not loop through any rows.
}
but If I do this
Query 2
String metatype = 'type1';
for(meta1 m : [SELECT Persona__c, metarelate__r.Name__c, metarelate__r.Type__c   from meta1 
                                                            WHERE metarelate__r.Active__c = true]){ 
       if(m.metarelate__r.Type__c = metatype){
                //does loop through rows that have Type__c = 'type1'.
       }
}
 The query has alot of records, so I want to do it the first way, to save on CPU Time. But it will only work the second way, which eats up CPU Time. Why is it that in Query1 the where Clause on Type__c Column is not working. FYI it's a picklist.