Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6353713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:27:33+00:00 2026-05-24T22:27:33+00:00

So I have implemented a google maps, using javascript to plot a polygon. I

  • 0

So I have implemented a google maps, using javascript to plot a polygon. I use getBounds to get the latLongs. Then I call a database (postcodes), which contains each lat long for each postcode in the UK.

This query looks like:

SELECT * FROM `postcode`.`postcodeGoogle` WHERE (`lat` BETWEEN '$lat1' AND '$lat2')
    AND (`long` BETWEEN '$long1' AND '$long2')

Which is fine, returns the right data.

I then have a second database, address_list, which contains every address in the UK (at the moment it only contains Kettering area, so 12,000 rows). I do a while loop on the first query and then on each loop run this query:

SELECT * FROM `digital_hub`.`address_list` WHERE `postcode`='".$row['postcode']."'

Then I add the latlong of the postcode to a variable:

$resultE = $resultE."(".$row['lat'].", ".$row['long'].") || ";

This then gets echoed out at the end of the loops.

This page is called via jQuery:

$.get("php/properties.php?bounds="+bounds, function(data){
        var theLatLongs = data.split(" || ");
        totalcount = 0;

        for(x in theLatLongs){
            var theLatLong = "";
            var latLong = theLatLongs[x].substr(1);
            var latLong = latLong.slice(0, -1);
            var theLatLong = latLong.split(", ");
            var thelat = theLatLong[0];
            var thelong = theLatLong[1];

                totalcount = totalcount+1;

        }
    $('#totalcount').html('<h6><span>'+totalcount+'</span> Households found</h6>Filtered by location');
});

It all works fine (I think). It’s just incredibly slow. I know facebook have much better resources, but there create advert filterer is amazingly quick. I will also be implementing further filters. I tried a join but the time difference didn’t seem to massive. Sometimes it doesn’t even return results at all and crashes my mysql service…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:27:34+00:00Added an answer on May 24, 2026 at 10:27 pm

    there are 3 sources that can slow the code: mysql, php, js.

    the first thing I would do is run the sql (the join version), in a tool like toad or do a php file that outputs the raw result. You can add console.time/console.timeEnd to js, and mictrotime in php.

    another “fast and dirty” check is to past “your_server”/php/properties.php?bounds=YourBounds,
    and check the result. it will give you some indication.

    If you are certain it’s sql, try to index digital_hub.address_list.postcodes, postcode.postcodeGoogle.lat, and postcode.postcodeGoogle.long.

    Then, in your php “raw” script (or your sql tool), try to call the query with less column,
    or even with “select count(*)“. If the “select count(*)” is way faster, that means that the returning value is slowing the system. This is typical of empty (non null) date fields by example.

    But they key is simple, time the different parts of the process to isolate the bottleneck.

    console.time('load');
    $.get("php/properties.php?bounds="+bounds, function(data){
            console.timeEnd('load');
            console.time('parse');
            var theLatLongs = data.split(" || ");
            totalcount = 0;
    
            for(x in theLatLong ){
                var theLatLong = "";
                var latLong = theLatLongs[x].substr(1);
                var latLong = latLong.slice(0, -1);
                var theLatLong = latLong.split(", ");
                var thelat = theLatLong[0];
                var thelong = theLatLong[1];
    
            totalcount = totalcount+1;
            }
    console.timeEnd('parse');
        console.time('display');    
        $('#totalcount').html('<h6><span>'+totalcount+'</span> Households found</h6>Filtered by location');
        console.timeEnd('display');        
    });
    

    on a side note, you might consider json data. (and review your use of thelatlong js var, but I guess you are debugging)
    in php:

    while ($row = msqlqresult) {
        $resultArray[] = $row;  
    }
    
    $resultJson = json_encode($resultArray);
    

    in js:

    console.time('load');
    $.getJSON("php/properties.php", {bounds: bounds}, function(data){
            console.timeEnd('load');
            console.time('parse');
            totalcount = 0;
    
            for(var x in data){
                var thelat = theLatLong[x].lat;
                var thelong = theLatLong[x].long;
    
                totalcount = totalcount+1;
            }
        console.timeEnd('parse');
        console.time('display');    
        $('#totalcount').html('<h6><span>'+totalcount+'</span> Households found</h6>Filtered by location');
        console.timeEnd('display');
    

    });

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have successfully implemented code to plot multiple locations on google maps dynamically. Solution:
as part of my last.fm/google maps event mashup, I have to plot markers dynamically
I have successfuly implemented Google Maps Places V3 autocomplete feature on my input box
I have implemented tracing based on System.Diagnostics. I am also using a System.Diagnostics.TextWriterTraceListener, and
We have implemented a popup window as a modal dialog using the IE method:
I have a class based on google.maps.OverlayView which implements a custom replacement for a
I'm building an ASP.NET MVC site where I want to have a Google Maps
Just recently Google made available Maps GL on the GMaps platform. We have an
I have implemented admob code as given in google site (http://code.google.com/mobile/ads/docs/android/fundamentals.html) as described in
I am writing a drawing program, Whyteboard -- http://code.google.com/p/whyteboard/ I have implemented image rotating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.