+ Reply to Thread
Results 1 to 4 of 4
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
  1. #1
    lashak is offline Junior Member
    Join Date
    Jan 2010
    Posts
    5

    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); 

  2. #2
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    How many records is this returning?

  3. #3
    lashak is offline Junior Member
    Join Date
    Jan 2010
    Posts
    5
    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

  4. #4
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    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

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO 3.5.2