Very slow zip query [closed]

0
date_default_timezone_set('America/Sao_Paulo');
include 'conn.php';
    $query = $mysql_adv->query("SELECT * FROM dados");
    while($row = $query->fetch_array()){
        $url  = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=";
        $url .= $row['cep_adv']."&destinations=".$_GET['cep'];
        $url .= "&language=pt&mode=car&key=AIzaSyDL6_dJ-Mbi_03_g6lHhWibxY22Z2UeYZQ";
        $json = file_get_contents($url);
        $json_data = json_decode($json, true);
    } 

I am doing a query with 30 ceps and this is very slow loading! about 1 minute, what can I do?

    
asked by anonymous 12.06.2018 / 16:11

1 answer

1

Given that you are using a public service, there is not much you can do other than to purchase a private service or have your own zip code database.

The Google website receives many requests, possibly they do not provide many computational resources for open services like this zip query.

    
12.06.2018 / 16:15