Connecting Tech Pros Worldwide Help | Site Map

while loops within while loops causing huge memory problem

 
LinkBack Thread Tools Search this Thread
  #1  
Old October 18th, 2006, 05:55 PM
monomaniac21
Guest
 
Posts: n/a
Default while loops within while loops causing huge memory problem

hi all

i have a script that retrieves rows from a single table, rows are
related to eachother and are retrieved by doing a series of while loops
within while loops. bcos each row contains a text field they are fairly
large. the net result is that when 60 or so results are reitreved the
page size is 400kb! which takes too long to load. is there a way of
shorterning this? freeing up the memory say, bcos what is actually
displayed is not that much, its just the use of multiple loops (about
10) that does it i think


  #2  
Old October 18th, 2006, 08:15 PM
Moot
Guest
 
Posts: n/a
Default Re: while loops within while loops causing huge memory problem


monomaniac21 wrote:
Quote:
hi all
>
i have a script that retrieves rows from a single table, rows are
related to eachother and are retrieved by doing a series of while loops
within while loops. bcos each row contains a text field they are fairly
large. the net result is that when 60 or so results are reitreved the
page size is 400kb! which takes too long to load. is there a way of
shorterning this? freeing up the memory say, bcos what is actually
displayed is not that much, its just the use of multiple loops (about
10) that does it i think
If the page size delivered to the browser is 400kb, then it's 400kb's
worth of data. You can't change that by freeing up memory in PHP.

If the page is getting too large, then consider using pagination to
break up all that data into smaller sets across multiple pages. For
instance, limit each page to only show 100 records and provide
Previous/Next links to navigate across all the results.

Moot

  #3  
Old October 19th, 2006, 06:25 AM
Kimmo Laine
Guest
 
Posts: n/a
Default Re: while loops within while loops causing huge memory problem

"monomaniac21" <mcyi2mr3@googlemail.comwrote in message
news:1161195237.493677.322990@e3g2000cwe.googlegro ups.com...
Quote:
hi all
>
i have a script that retrieves rows from a single table, rows are
related to eachother and are retrieved by doing a series of while loops
within while loops. bcos each row contains a text field they are fairly
large. the net result is that when 60 or so results are reitreved the
page size is 400kb! which takes too long to load. is there a way of
shorterning this? freeing up the memory say, bcos what is actually
displayed is not that much, its just the use of multiple loops (about
10) that does it i think

Clearly the code needs to be optimized. Depending how bad the design is, you
should start looking at the query string, maybe the database structure. Now
it just doesn't sound too smart if it takes ten nested while loops to pull
out some simple data... But without seeing the actual code it's very
difficult to say anything more specific.

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
spam@outolempi.net | rot13(xvzzb@bhgbyrzcv.arg)


  #4  
Old October 19th, 2006, 06:45 AM
Rik
Guest
 
Posts: n/a
Default Re: while loops within while loops causing huge memory problem

Kimmo Laine wrote:
Quote:
"monomaniac21" <mcyi2mr3@googlemail.comwrote in message
news:1161195237.493677.322990@e3g2000cwe.googlegro ups.com...
Quote:
>hi all
>>
>i have a script that retrieves rows from a single table, rows are
>related to eachother and are retrieved by doing a series of while
>loops within while loops. bcos each row contains a text field they
>are fairly large. the net result is that when 60 or so results are
>reitreved the page size is 400kb! which takes too long to load. is
>there a way of shorterning this? freeing up the memory say, bcos
>what is actually displayed is not that much, its just the use of
>multiple loops (about 10) that does it i think
>
>
Clearly the code needs to be optimized. Depending how bad the design
is, you should start looking at the query string, maybe the database
structure. Now it just doesn't sound too smart if it takes ten nested
while loops to pull out some simple data... But without seeing the
actual code it's very difficult to say anything more specific.
A self-referential table of a adjacency model often takes either a lot of
while loops or a lot of joins. It might be usefull to switch to a nested
model in that case.

http://dev.mysql.com/tech-resources/...ical-data.html

Neither explains a 400KB HTML page offcourse, if the actual data is small,
something else is definately wrong.

Grtz,
--
Rik Wasmus


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.