This is a discussion on SOQL and PHP improvement of Account Query??? within the Salesforce PHP Tutorials forums, part of the Salesforce category; I have had to update the php.ini max execution time to 300
-
SOQL and PHP improvement of Account Query???
I have had to update the php.ini max execution time to 300 seconds for the below script to complete. Has anyone run into long running queries where they were able to improve performance by tuning the query? Any help on this would be greatly appreciated. Thank you,
PHP Code:
$query = "SELECT a.Vertical__c From Account a Where a.Status__c Like 'Active%'
ORDER BY a.Vertical__c ASC";
$options = new QueryOptions(2000);
$queryResult = new QueryResult($response);
!$done = false;
if ($queryResult->size > 0)
{
while (!$done)
{
foreach ($queryResult->records as $record)
{
if (!$record->fields->Vertical__c =="")
{
$vertArray[]=$record->fields->Vertical__c;
}
}
if ($queryResult->done != true)
{
// Get Next Batch of Records
try
{
$response = $mySforceConnection->queryMore($queryResult->queryLocator);
$queryResult = new QueryResult($response);
}
catch (Exception $e)
{
print_r($mySforceConnection->getLastRequest());
echo $e->faultstring;
}
}
else
{
$done = true;
}
}
}
}
$dbarray = array_unique($vertArray);
-
How many records is this returning?
-
Here is the results:
Size of records: 257244
This is what the array_Unique gives me and the result I need to pass back.
Asset & Svc. Intensive
ESM
Fashion
Food & Beverage
HC
Healthcare
Industry Markets
International
Manufacturing
Public Sector
Public Services
Retail
Service Industries
-
That is quite a bit of records to be retrieving! I don't think that there is anything that you are doing wrong. If you are getting the records all at one time, maybe you could split them up and batch them before you query more.
Have you thought about getting all these records in a local database and then writing your query locally? Say MySQL or Oracle?
~Mike
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
Bookmarks