Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Re: nph-build problem -- abort or looping

Quote Reply
Re: nph-build problem -- abort or looping In reply to
Hi pugdog,

It works the following way:

$offset=0; # Logic Bug : should be set to 1
$limit=100; # Number of results to handle in one loop
...
The main logic is to keep memory usage low. $limit=100; is used to define how many categorys are loaded to memory and stored in the array to be built. If you set it to low it will increase your building time because you have to query the database to often. In nph-build.cgi the number of SQL querys = (Number of Categorys) / ($limit).
In your solution you set $limit= number of categorys. This means the whole recordset with all categories are loaded to memory. When you have many categories you will get memory errors. (Im not shure when perl gives up. But every programming language has its definitions of the maximum size of an array or hash)


WHILE(1) # will always be TRUE
$categories_r = $CATDB->query ( { ID => '*', mh => $limit, nh => $offset+1,.... # should be $offset,
# selects all categorys LIMIT ($offset * $limit), $limit
# see DBSQL.pm sub query
# and returns $limit categorys to work with in the next foreach loop
$offset++;
# increments lets call it the page counter
# in DBSQL.pm $offset (nh) gets multiplied with $limit (mh)
# # First let's see how many hits we got.
my ($offset, $table, $query);
$offset = ($nh -1) * $maxhits;

last unless... # quit loop if no results

I think this could be the problem of some users
im MySQL if the LIMIT statement is defined:

"The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments. If two arguments are given, the first specifies the offset of the first row to return, the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1)."

Now what I didn't find is the reaction of MySQL if the offset exeeds the number of rows. Maybe older versions of MySQL asume 0 if an invalid value (>maxrows) is given.
This would be an explanation for the endless loop. It works fine however with my version.

To check this it would be nice if some user with the endless-loop problem could use their SQL-monitor in admin and try following statement:

SELECT * FROM Category LIMIT "Offset", 100
"Offset should be replaced with a number larger than the number of categorys.


A solution for users having problems with the endless-loop would be
check the number of categorys
insert an internal counter
exit the loop if the counter exeeds the num of cats

I hope it helps,
regards, alexander

Subject Author Views Date
Thread nph-build problem -- abort or looping pugdog 11629 Aug 29, 2000, 12:32 PM
Thread Re: nph-build problem -- abort or looping
Stealth 11494 Aug 29, 2000, 12:38 PM
Thread Re: nph-build problem -- abort or looping
qango 11389 Aug 29, 2000, 1:32 PM
Post Re: nph-build problem -- abort or looping
Stealth 11379 Aug 29, 2000, 1:40 PM
Thread Re: nph-build problem -- abort or looping
startpoint 11405 Aug 29, 2000, 2:24 PM
Thread Re: nph-build problem -- abort or looping
Stealth 11393 Aug 29, 2000, 3:39 PM
Thread Re: nph-build problem -- abort or looping
qango 11398 Aug 29, 2000, 3:47 PM
Thread Re: nph-build problem -- abort or looping
Stealth 11414 Aug 29, 2000, 3:52 PM
Thread Re: nph-build problem -- abort or looping
pugdog 11395 Aug 30, 2000, 1:25 AM
Thread Re: nph-build problem -- abort or looping
Alex404 11403 Aug 30, 2000, 3:30 AM
Thread Re: nph-build problem -- abort or looping
pugdog 11380 Aug 30, 2000, 6:11 AM
Thread Re: nph-build problem -- abort or looping
Alex404 11370 Aug 30, 2000, 6:36 AM
Thread Re: nph-build problem -- abort or looping
Stealth 11350 Aug 30, 2000, 7:51 AM
Thread Re: nph-build problem -- abort or looping
AndreasH 11379 Aug 30, 2000, 4:04 PM
Thread Re: nph-build problem -- abort or looping
Stealth 11356 Aug 30, 2000, 5:05 PM
Thread Re: nph-build problem -- abort or looping
AndreasH 11356 Aug 30, 2000, 5:20 PM
Thread Re: nph-build problem -- abort or looping
pugdog 11381 Aug 30, 2000, 6:02 PM
Thread Re: nph-build problem -- abort or looping
AndreasH 11361 Aug 30, 2000, 6:14 PM
Thread Re: nph-build problem -- abort or looping
pugdog 11381 Aug 30, 2000, 6:29 PM
Thread Re: nph-build problem -- abort or looping
AndreasH 11367 Aug 30, 2000, 6:50 PM
Post Re: nph-build problem -- abort or looping
pugdog 11357 Aug 30, 2000, 7:30 PM
Thread Re: nph-build problem -- abort or looping
Alex404 11378 Aug 31, 2000, 12:42 AM
Thread Re: nph-build problem -- abort or looping
AndreasH 11353 Aug 31, 2000, 10:58 AM
Thread Re: nph-build problem -- abort or looping
pugdog 11329 Aug 31, 2000, 2:06 PM
Thread to Alex
AndreasH 4438 Aug 31, 2000, 2:51 PM
Thread Re: to Alex
Stealth 4415 Aug 31, 2000, 3:09 PM
Thread Re: to Alex
AndreasH 4423 Aug 31, 2000, 3:18 PM
Post Re: to Alex
Stealth 4396 Aug 31, 2000, 3:25 PM
Thread Re: nph-build problem -- abort or looping
AndreasH 4435 Aug 31, 2000, 4:30 PM
Thread Re: nph-build problem -- abort or looping
pugdog 4407 Aug 31, 2000, 5:51 PM
Thread Re: nph-build problem -- abort or looping
AndreasH 4405 Aug 31, 2000, 6:27 PM
Thread Re: nph-build problem -- abort or looping
Alex404 4401 Sep 1, 2000, 1:38 AM
Post Re: nph-build problem -- abort or looping
AndreasH 4389 Sep 1, 2000, 3:32 AM
Post To all who helped me!
AndreasH 4378 Sep 1, 2000, 4:44 PM
Post Re: nph-build problem -- abort or looping
Alex404 11363 Aug 30, 2000, 7:50 AM