insert big array into database
You should avoid executing insert many times. It is enough to call -&gt;fields multiple times, like this:

$query = db_insert('reservation');
foreach ($array as $room_id =&gt; $item) {
  foreach ($item as $reservation) {
    $query-&gt;fields(
      array(
        'room_id' =&gt; $room_id, 
        'id' =&gt; $reservation['id'],
        'start' =&gt; $reservation['start'],
        'end' =&gt; $reservation['end'],
        'status' =&gt; $reservation['status']
      )
    );
  }
}
$query-&gt;execute();


This will speed up things, allowing database to prepare space for new data in one step, but with 30 thousands of records it still may take time. Be sure to tune your database accordingly - but that's out of the scope of Drupal Answers.

If you can't optimize DB enough, consider using Batch API for the job. It will make things a bit slower than the code above, but by importing a hundred or two each step you will avoid HTTP connection timeouts, PHP timeouts etc. Just make sure you only execute once per step with hundred records - even with Batch API it is good approach to group rows in as few inserts as practical.