PHP code seems too slow for the database? Any ideas?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

tloftis
Forum Newbie
Posts: 21
Joined: Thu Apr 10, 2008 9:43 am

Re: PHP code seems too slow for the database? Any ideas?

Post by tloftis »

I am working on getting the code sorted so I can get some answers. thanks for the input so far. It may get the programmer thinking about something new.
tloftis
Forum Newbie
Posts: 21
Joined: Thu Apr 10, 2008 9:43 am

Re: PHP code seems too slow for the database? Any ideas?

Post by tloftis »

can you send php script as a file?
tloftis
Forum Newbie
Posts: 21
Joined: Thu Apr 10, 2008 9:43 am

Re: PHP code seems too slow for the database? Any ideas?

Post by tloftis »

distances are calculated by long and lat and it is a script in itself.
JoeCommodore
Forum Newbie
Posts: 15
Joined: Fri Oct 01, 2010 10:16 pm

Re: PHP code seems too slow for the database? Any ideas?

Post by JoeCommodore »

tloftis wrote:distances are calculated by long and lat and it is a script in itself.
I'm not a math wiz but such queries with lat/longitude have been done in SQL.. Maybe someone can provide the resources on doing it.

A quick search found this discussion on zip code proximity searches - which looks promising: http://forums.mysql.com/read.php?23,3868,3868#msg-3868
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: PHP code seems too slow for the database? Any ideas?

Post by John Cartwright »

Your not going to get very far with us until you post some code! Theory is only as good as it's implementation.

I'm not saying you need to post your code, but it would certainly allow us to suggest practical improvements.

To each his own though.
tloftis
Forum Newbie
Posts: 21
Joined: Thu Apr 10, 2008 9:43 am

Re: PHP code seems too slow for the database? Any ideas?

Post by tloftis »

Jonah Bron wrote:I believe it could be either way. It could be a grossly inefficient search mechanism, or the server could be really really wimpy. In fact, thinking about it, the former seems like it would be the most likely.

The speed advantage of using Java would be negligible.
how can I test the speed of the server to see if that is what it is?
tloftis
Forum Newbie
Posts: 21
Joined: Thu Apr 10, 2008 9:43 am

Re: PHP code seems too slow for the database? Any ideas?

Post by tloftis »

JoeCommodore wrote:
tloftis wrote:distances are calculated by long and lat and it is a script in itself.
I'm not a math wiz but such queries with lat/longitude have been done in SQL.. Maybe someone can provide the resources on doing it.

A quick search found this discussion on zip code proximity searches - which looks promising: http://forums.mysql.com/read.php?23,3868,3868#msg-3868
the lat and long are done in the SQL database.
tloftis
Forum Newbie
Posts: 21
Joined: Thu Apr 10, 2008 9:43 am

Re: PHP code seems too slow for the database? Any ideas?

Post by tloftis »

Code: Select all

SELECT a.*, u.user_status, u.user_active, u.zip, t.distance, tp.photo, (SELECT make_title FROM make_master m WHERE m.make_id = a.make_id) AS make_title, (SELECT model_title FROM model_master mo WHERE mo.model_id = a.model_id) AS model_title, (SELECT graphic_tile FROM order_master om WHERE om.user_id = a.user_id) AS graphic_tile FROM ad_master a LEFT JOIN user_master u ON u.user_id = a.user_id LEFT JOIN temp_distance_calculation t ON t.car_id = a.ad_ms_id LEFT JOIN temp_photo_calculation tp ON tp.car_id = a.ad_ms_id LEFT JOIN photo_master p ON p.vin = a.vin WHERE a.ad_ms_id IN ('15889','16174','16501','1670'22214','22215','22216','22217','22218','22219','22220') AND a.user_id != 0 AND u.user_status = 'p' AND u.user_active = '1' AND u.zip != '' AND ROUND(t.distance) <= '10'
I cut out about half of the zip-codes because this was too long. This is what is happening now when you try to search on http://nabacar.com.
tloftis
Forum Newbie
Posts: 21
Joined: Thu Apr 10, 2008 9:43 am

Re: PHP code seems too slow for the database? Any ideas?

Post by tloftis »

I think that code is what you wanted.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: PHP code seems too slow for the database? Any ideas?

Post by Benjamin »

Post the db schema and the slow query(s).
tloftis
Forum Newbie
Posts: 21
Joined: Thu Apr 10, 2008 9:43 am

Re: PHP code seems too slow for the database? Any ideas?

Post by tloftis »

I will have to find out where to get those. sigh.... lol let me browse around in the schema.
tloftis
Forum Newbie
Posts: 21
Joined: Thu Apr 10, 2008 9:43 am

Re: PHP code seems too slow for the database? Any ideas?

Post by tloftis »

I wish I personally knew someone on this site and I would just let them go and get it for me. then I could learn what I need to do.
Post Reply