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 11724 Aug 29, 2000, 12:32 PM
Thread Re: nph-build problem -- abort or looping
Stealth 11590 Aug 29, 2000, 12:38 PM
Thread Re: nph-build problem -- abort or looping
qango 11486 Aug 29, 2000, 1:32 PM
Post Re: nph-build problem -- abort or looping
Stealth 11474 Aug 29, 2000, 1:40 PM
Thread Re: nph-build problem -- abort or looping
startpoint 11501 Aug 29, 2000, 2:24 PM
Thread Re: nph-build problem -- abort or looping
Stealth 11490 Aug 29, 2000, 3:39 PM
Thread Re: nph-build problem -- abort or looping
qango 11493 Aug 29, 2000, 3:47 PM
Thread Re: nph-build problem -- abort or looping
Stealth 11510 Aug 29, 2000, 3:52 PM
Thread Re: nph-build problem -- abort or looping
pugdog 11491 Aug 30, 2000, 1:25 AM
Thread Re: nph-build problem -- abort or looping
Alex404 11499 Aug 30, 2000, 3:30 AM
Thread Re: nph-build problem -- abort or looping
pugdog 11476 Aug 30, 2000, 6:11 AM
Thread Re: nph-build problem -- abort or looping
Alex404 11465 Aug 30, 2000, 6:36 AM
Thread Re: nph-build problem -- abort or looping
Stealth 11445 Aug 30, 2000, 7:51 AM
Thread Re: nph-build problem -- abort or looping
AndreasH 11474 Aug 30, 2000, 4:04 PM
Thread Re: nph-build problem -- abort or looping
Stealth 11452 Aug 30, 2000, 5:05 PM
Thread Re: nph-build problem -- abort or looping
AndreasH 11452 Aug 30, 2000, 5:20 PM
Thread Re: nph-build problem -- abort or looping
pugdog 11476 Aug 30, 2000, 6:02 PM
Thread Re: nph-build problem -- abort or looping
AndreasH 11458 Aug 30, 2000, 6:14 PM
Thread Re: nph-build problem -- abort or looping
pugdog 11477 Aug 30, 2000, 6:29 PM
Thread Re: nph-build problem -- abort or looping
AndreasH 11463 Aug 30, 2000, 6:50 PM
Post Re: nph-build problem -- abort or looping
pugdog 11452 Aug 30, 2000, 7:30 PM
Thread Re: nph-build problem -- abort or looping
Alex404 11473 Aug 31, 2000, 12:42 AM
Thread Re: nph-build problem -- abort or looping
AndreasH 11449 Aug 31, 2000, 10:58 AM
Thread Re: nph-build problem -- abort or looping
pugdog 11424 Aug 31, 2000, 2:06 PM
Thread to Alex
AndreasH 4475 Aug 31, 2000, 2:51 PM
Thread Re: to Alex
Stealth 4452 Aug 31, 2000, 3:09 PM
Thread Re: to Alex
AndreasH 4460 Aug 31, 2000, 3:18 PM
Post Re: to Alex
Stealth 4432 Aug 31, 2000, 3:25 PM
Thread Re: nph-build problem -- abort or looping
AndreasH 4472 Aug 31, 2000, 4:30 PM
Thread Re: nph-build problem -- abort or looping
pugdog 4444 Aug 31, 2000, 5:51 PM
Thread Re: nph-build problem -- abort or looping
AndreasH 4442 Aug 31, 2000, 6:27 PM
Thread Re: nph-build problem -- abort or looping
Alex404 4438 Sep 1, 2000, 1:38 AM
Post Re: nph-build problem -- abort or looping
AndreasH 4426 Sep 1, 2000, 3:32 AM
Post To all who helped me!
AndreasH 4415 Sep 1, 2000, 4:44 PM
Post Re: nph-build problem -- abort or looping
Alex404 11459 Aug 30, 2000, 7:50 AM