Performance loss large Database

#7
[eluser]jonez[/eluser]
Correct, the join would result in one massive recordset (array). Pulling one query then delegating by ID in PHP is considerably faster than performing 300 individual queries. Try it and see for yourself.

Something like this should work well;
Code:
$results = $this->db->query( $sql, $params )->result_array( );
$data = array( );

foreach ( $results as $result ) {
if ( !array_key_exists( $result[ 'id' ], $data ) ) {
  $data[ $result[ 'id' ] ] = array(
   'id' => $result[ 'id' ],
   'rows' => array( ),
  );
}

$data[ $result[ 'id' ] ][ 'rows' ][ ] = $data;
}

unset( $result, $results );


Messages In This Thread
Performance loss large Database - by El Forum - 10-19-2014, 08:23 AM
Performance loss large Database - by El Forum - 10-19-2014, 11:25 AM
Performance loss large Database - by El Forum - 10-19-2014, 11:26 AM
Performance loss large Database - by El Forum - 10-19-2014, 02:52 PM
Performance loss large Database - by El Forum - 10-19-2014, 05:00 PM
Performance loss large Database - by El Forum - 10-20-2014, 12:55 AM
Performance loss large Database - by El Forum - 10-20-2014, 05:16 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.