Reply to Re: Why is this script so slow?

Your name:

Reply:


Posted by Saul on 03/19/07 07:48

On 18 Mar, 22:10, "kenoli" <kenol...@gmail.com> wrote:
> The following code is extracting all fields from all records from a
> mysql database that has about 250 records in it. Firefox takes over
> one minute to extract these records and display them in rows in a
> table using the code included below. Safari takes about 30 seconds.
> Even after the page displays, the scrolling is a little eratic.
>
> When I use another script to extract the same data and display the
> first and last names in one column, it takes about 3 seconds from
> start to finish. So I believe it is not the database or the server.
> I can only conclude it is the script.

First thing is to add some timers to the script to see if you can work
out how long it is taking -
$start=time();
....your code
echo "end: ";time()-$start;

That will at least tell you if it server side or client side.

Second thing:
> $query = 'SELECT * FROM tbl_person ORDER BY last_name ASC;';

We obviously don't know what is in tbl_person, but for speed in MySQL
explicitly pick out just the fields that you are going to use. If you
have a large BLOB or TEXT field in the list, then this would be
slowing things down.

If it is a browser rendering problem then it could be confusion in the
page structure. I take it that this is an extract, but tables in
browsers don't tend to be rendered until they are complete - that is
the whole table has to be received before rendering. If you have a
complex table structure (eg tables with nested tables inside them), or
structural errors in the table such as a missing <tr> or extra <td> by
mistake then the browser will take it's time to work out what is
supposed to be where.

On a personal note, in-lining PHP in the HTML always looks very
difficult to debug to me. I don't know if this has speed issue but
long term it makes your code less maintainable and it becomes very
easy to introduce output bugs.


Saul
www.notanant.com
communities of websites

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация