I have table `arseh` that all field is primary key. All fields have index. It has 10,000,000 record.

```

         Arseh Table
------------------------------
|Code|ID|FromYear|ToYear|
-----------------------------
|1   |1 |1350    |1395  |
|2   |1 |1355    |1366  |
|2   |10|1395    |1395  |

```

PHP

```
function Calc($Code,$ID,$FromYear,$ToYear){
    $Handler = new DB();
    $Result=$Handler->query("select * from arseh where Code='".$Code."' and ID=".$ID." and FromYear='".$FromYear."' and ToYear='".$ToYear."'");
    return $Result;
}

```

I need call function Calc more than 10,000 times with different and random parameters.

**Problem:** this scenario(call Calc for 10,000 times) need 20 second to complete. how can decrease this time?

If i insert whole data of table to array one time and other time search in array instead select from table is better ?or not?