高效检索

低效代码

String profileid = COM_Util.getProfileIdToName(Label.LAB077);
     	List<user> userList = [SELECT contactId FROM user where profileid =:profileid and IsActive = true];
		List<id> conIdList = new List<id>();
		for(User u :userList){
			conIdList.add(u.contactId);
		}
		List<contact> conList = [select AccountId from contact where id in:conIdList];
		List<id> accIdList = new List<id>();
		for(Contact con :conList){
			accIdList.add(con.AccountId);
		}
		// 取引先のチェック
        List<Account> userCheckList = [select id
									        ,Name 
								        From Account 
								        where isdeleted = false 
								        and Name in:accNameList

								        and id in:accIdList];

高效代码

List<Contact> conList = [select id
								        ,Name
								        ,AccountId
								        ,Account.Name
								        ,Account.ACC_E_MAIL__c 
							        from contact 
							        where contact.CON_TYPE__c = '种别名' 
							        and id in  (select contactId 
										        from user
										        where profileid =:profileid 
										        and isActive=true )];

低效

Map<id,Contact> conMap = new Map<id,Contact>([select id,Name from Contact  where Account.Name LIKE :'%' + entryAccName + '%']);
List<plantApply__c> plaList = [select Id,PAP_ENTRY__r.Name from PlantApply__c where PAP_ENTRY__c in : conMap.keyset()]; //PAP_ENTRY__c is Contact


高效

List<plantApply__C> plaList2 = [select Id,PAP_ENTRY__r.Name from PlantApply__c where PAP_ENTRY__r.Account.Name LIKE :'%' + entryAccName + '%' ];




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值