Jump to content

Speeding up GeoDB query


adam84

Recommended Posts

This deals with Canadian Postal Code, for some reason we have a ton of them.

 

On my site, I have a search form, where the user enters their seach criteria, they enter in the postal code (X0X 0X0), then they select the distance they wanna search within (10km, 25km, 50km, etc).

 

When the user submits the form, I collect all the submitted data, and create my sql statement. I then call a function the queries my postal code database and the function returns all the postal codes in an array that are within the distance range (I didnt write the function). For instance I got over 150 different postal codes returned for a simple 25km search.

 

This is pretty much how my sql statement looks, except each postal code is different. My question is, is this how I should be doing this using the 'IN' or is there another more efficient way of doing thisa dn speeding it up.

 

SELECT * FROM userProfile WHERE userGender = 'F' AND age > 19 AND age < 31 AND pCode IN (
'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8', 'N6H 3K6, 'N7H 3K7', 'N8H 3K8')

*Sample query, can post an actual one later, I dont have the files on me

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.