You need to sign in to do that
Don't have an account?
krishna casukhela 7
searching value
Hello friends
I have 1 lakh records in account object.
I am using an apex class and I want to search for a particular account name .
How can I perform this search likewise I cannot use [select Name from account limit 50000] because what happens if the account name is after the limit value.
I do not want to use batch apex , only apex class
I hope I am clear.
Kindly let me know
Thanks
krishna
I have 1 lakh records in account object.
I am using an apex class and I want to search for a particular account name .
How can I perform this search likewise I cannot use [select Name from account limit 50000] because what happens if the account name is after the limit value.
I do not want to use batch apex , only apex class
I hope I am clear.
Kindly let me know
Thanks
krishna
As long as you are not fetching more than 50000 records you should not hit the limit. Since you are seraching only for a particular Account Name, you can go ahead without a batch apex, If you are sure that you there aren't more than 50000 records with the same name.
will ur code work even if there are 2 lakh records:?
I have put my code here for ur ereference . Please let me know if SOQL query impacts performance if there are 1 lakh / 2 laksh records or more.
<apex:page standardController="Account"
extensions="MySOSLSearch"
tabStyle="Account">
<apex:form >
<apex:inputText value="{!SearchString}"/>
<apex:commandButton action="{!Search}"
value="SearchAccount"/>
<apex:pageBlock mode="DisplayAccount Info">
<apex:pageBlockTable value="{!accts}"
var="a">
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.Type}"/>
<apex:column value="{!a.Industry}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
public class MySOSLSearch
{
public String SearchString{get;set;}
public list<Account> accts;
public MySOSLSearch(ApexPages.StandardController controller)
{
}
public list<Account> getaccts()
{
return accts;
}
public PageReference Search()
{
list<list<Account>> lstr = [FIND : SearchString IN ALL FIELDS RETURNING Account(Name, Type, Industry)];
accts =(list<account>)lstr[0]; //for single record
return null;
}
}
Please let me know performance of above code .
thanks
sonali