NYCPHP Meetup

NYPHP.org

[nycphp-talk] Sssllllooooowwwww Page

Brent Baisley brent at landover.com
Tue Mar 8 13:35:14 EST 2005


I would first start troubleshooting where the problem is. Put some 
timers in your code that gets displayed on the web page so you can see 
what piece took the longest time. I assume you are using some sort of 
output buffering, which will allow you to see how long it takes to 
actually deliver the result from the server to the client. I always 
build up my web page in a variable, then I have a single echo at the 
end of my code that delivers it to the client.

If you are not using output buffering, then network latency may be 
what's killing you. If you are delivering the web page piece meal, 
which it looks like what you are doing, you are probably using far more 
network packets than should and not taking advantage of http 
compression. You can do a trace route to your clients ip address to get 
an idea of network latency. Remember, cable is a share connection, so 
if there are lots of people with cable modems in your clients 
neighborhood, there may be lots of collisions. The more network packets 
you require to deliver your data, the more likely it is there will be a 
collision.

My recommendation is to change you code so you are storing everything 
in a variable, then echo the variable when you have everything. That 
will probably speed everything up considerably.


On Mar 8, 2005, at 12:06 PM, harvey wrote:

> Hello NYPHP,
>
> I've got a page that works totally fine for me. Takes a few seconds to 
> load on cable connection with IE 6 PC. Works fine for a colleague with 
> DSL on the Mac (not sure which browser). But for the most important 
> person (client!) the page is taking over a minute and a half to load. 
> He's on Win XP and IE (probably 6) with cable connection.
>
> Relevant details are below. Basically, there's a table of shows, a 
> table of bands, and a table that connects the two so you know which 
> bands are playing in which shows. The admin chooses a show and sees a 
> list of about 500-1000 bands with the current bands for that show 
> already checked. The admin can uncheck them, check others, etc, and 
> update the show.
>
> Any ideas if the slowness in loading might be due to the select 
> statement? Is there a more efficient query structure? Or maybe just 
> writing the 1000 form inputs is taking too long? I was thinking about 
> getting rid of the show/band array table and just adding 10 fields to 
> the show table: band1_fid, band2_fid, etc... That would probably speed 
> things up, but all the work was already done for the current  method 
> and it works totally fine (except too slow for the client)...
>
> Thanks in advance for any suggestions!
>
> Harvey
>
>
> $show_id is a passed variable
>
> music_bands:  (List of bands)
> band_id
> band_name
>
> music_show_bands_array: (Keeps track of which bands are in which shows)
> s_b_id
> show_fid
> band_fid
>
> SELECT music_bands.band_id AS id, music_bands.band_name AS band, 
> music_show_bands_array.s_b_id AS inthere
> FROM music_bands
> LEFT JOIN music_show_bands_array ON ((music_show_bands_array.band_fid 
> = music_bands.band_id) AND (music_show_bands_array.show_fid = 
> $show_id))
> ORDER BY music_subcats.subcat_name ASC
>
> Then there's a form with about 500-1000 bands listed as follows:
> <?php do { ?>
> <input name="band_fid[]" type="checkbox" value="<?php echo 
> $row_bands['id']; ?>" <?php if ($row_bands['inthere']) { echo " 
> checked"; } ?>>
> <?php } while ($row_bands = mysql_fetch_assoc($bands)); ?>
>
>
>
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
>
>
-- 
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577




More information about the talk mailing list