I have an extremely large table ~a billion rows.
foreach($idArray as $id){
     'SELECT DIE_X, DIE_Y, LOG_INDEX, TREND_ELEMENT, TREND_DATA FROM trend_data_level_5 WHERE TREND_INDEX =' $id;
     $result = mysql_query($query);
}
This approach takes TOO long as my table grows larger and larger. I'm using an innoDB engine for my SQL database.
I ran a timer and the above loop took ~17 seconds for a table size of ~15 milion. Imagine, how long this would take for a billions rows!
Can I get this time down significantly? If so, what's the best approach?
EDIT: Here's what the table looks like
------------------------------------------------------------------------------------------------------------------------------------------------+
| Table              | Create Table
                                                                                                                                                |
+--------------------+--------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------+
| trend_data_level_5 | CREATE TABLE trend_data_level_5 (
  LOG_INDEX int(5) DEFAULT NULL,
  DIE_X int(3) DEFAULT NULL,
  DIE_Y int(3) DEFAULT NULL,
  TREND_INDEX int(10) DEFAULT NULL,
  TREND_ELEMENT varchar(3) DEFAULT NULL,
  TREND_DATA int(5) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+--------------------+--------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------+
 
     
     
     
    