cur.execute("select count(*)/60 from new_query_log where starttime > now() - interval '1min'")
dbload = int(cur.fetchone()[0])
-BLOCK_LIMIT = max(BLOCK_LOWER, BLOCK_UPPER - BLOCK_LOADFAC * (dbload - 70))
+BLOCK_LIMIT = max(BLOCK_LOWER, BLOCK_UPPER - BLOCK_LOADFAC * (dbload - 75))
BULKLONG_LIMIT = max(BULK_LOWER, BULKLONG_LIMIT - BULK_LOADFAC * (avgload - 14))
+if len(prevbulks) > 85:
+ BLOCK_LIMIT = BLOCK_LOWER
# get the new block candidates
cur.execute("""
WHERE starttime > now() - interval '1 hour' GROUP BY ipaddress) as i
WHERE count > %s)
UNION
- (SELECT ipaddress, count * 4 FROM
+ (SELECT ipaddress, count * 3 FROM
(SELECT ipaddress, sum(case when endtime is null then 1 else 1+date_part('epoch',endtime-starttime) end) as count FROM new_query_log
WHERE starttime > now() - interval '10 min' GROUP BY ipaddress) as i
WHERE count > %s)) as o