You are here: Re: Have a few php script questions « All PHP « IT news, forums, messages
Re: Have a few php script questions

Posted by J.O. Aho on 11/25/05 11:04

Julie wrote:
> Thanks for your great response.
> That makes sense. I tried to put some output in the loop that goes through
> each record, but it seems that the delay is before that, perhaps here:
> // delay is with this command
> $theresults=mysql_query( $sql )

Yes, this takes time if you have a large amount of entries that you need to
load, you should try to limit things as much as possible, so you get as few
results as possible, as a high amount results consumes time and memory and
http transports has a default timeout time of 180s and in php.ini there is
setting for how long a php script can run, how long time it's allowed to
collect data and how much memory it's allowed to use.

; Maximum execution time of each script, in seconds
max_execution_time = 30

; Maximum amount of time each script may spend parsing request data
max_input_time = 60

; Maximum amount of memory a script may consume (8MB)
memory_limit = 8M


> //then it is ok here and processes loop quickly
> while( $row = mysql_fetch_object( $theresults ) )

At this point you have got all the data.


> I think it is because it is loading in over 80000 records from mysql
> database in this query?
> Is there a command or other method I can use that will not load the whole
> dataset at once, but only one record at a time? Please assist

As I don't know what you want to do, so it's difficult to give you a good
hint, but you can use LIMIT in your query and you get a limited amount of
rows, and you can use it to get row in the middle of the list.

# Get max the 10 first lines
SELECT * FROM mytable LIMIT 10

# Get the 10th to 20th line (first entry is number 0)
SELECT * FROM mytable LIMIT 9,10

As you have su many rows in your database, you never want to see all of them
at once, which makes that you should never do a

SELECT * FROM mytable;

and let the database do as much of the data manipulation and not load values
to the php and modify something and then store it back.


//Aho

 

Navigation:

[Reply to this 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

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