473,408 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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

Oct 18 '06 #1
3 2385

monomaniac21 wrote:
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

Oct 18 '06 #2
"monomaniac21" <mc******@googlemail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
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
sp**@outolempi.net | rot13(xv***@bhgbyrzcv.arg)
Oct 19 '06 #3
Rik
Kimmo Laine wrote:
"monomaniac21" <mc******@googlemail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
>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
Oct 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: Andrew Koenig | last post by:
PEP 315 suggests that a statement such as do: x = foo() while x != 0: bar(x) be equivalent to while True:
34
by: Adam Hartshorne | last post by:
Hi All, I have the following problem, and I would be extremely grateful if somebody would be kind enough to suggest an efficient solution to it. I create an instance of a Class A, and...
3
by: RobG | last post by:
A little while ago I opined that do/while loops are harder to read than for loops, and therefore I preferred using for loops. However, it was pointed out that do/while has significant...
6
by: Jain, Pranay Kumar | last post by:
Hi All, We have created a simple application that takes a dataset and generates the data in Excel schema format. It uses an xslt file to do the transformation for excel 2002 and so on. We are...
2
by: VM | last post by:
When I display data to a Windows datagrid I usually fill the underlying table (in another class) and then, once it contains all the data, I attach it to the grid. But there are some processes that...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory†exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
9
by: liljencrantz | last post by:
Hi, I have a piece of code that uses hashtables to store pointers to various bits of data. The hashtable sees all pointers as const void *, while the application obviously uses various other...
9
by: none | last post by:
Hi all, First, let me preface this by the fact that I'm completely new to the language, but not to programming in general. I'm trying to get my feet wet with something near and dear to my...
5
by: ertis6 | last post by:
Hi all, I need to calculate a value inside 8 nested for loops. 2 additional for loops are used during calculation. It was working fine with 4 loops. My code is like this: ... for(int i1=0;...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.