Maybe that's the problem: for some reason pihole doesn't use the prepared value but instead calculates the number of distinct domains from vw_gravity again....
// Checking for smaller than GRAVITY_LIST is omitted due to list being unsigned
if(list >= UNKNOWN_TABLE)
{
logg("gravityDB_getTable(%u): Requested list is not known!", list);
return false;
}
char *querystr = NULL;
// Build correct query string to be used depending on list to be read
if(list != GRAVITY_TABLE && asprintf(&querystr, "SELECT COUNT(DISTINCT domain) FROM %s", tablename[list]) < 18)
{
logg("readGravity(%u) - asprintf() error", list);
return false;
}
// We get the number of unique gravity domains as counted and stored by gravity. Counting the number
// of distinct domains in vw_gravity may take up to several minutes for very large blocking lists on
// very low-end devices such as the Raspierry Pi Zero
else if(list == GRAVITY_TABLE && asprintf(&querystr, "SELECT value FROM info WHERE property = 'gravity_count';") < 18)
{
logg("readGravity(%u) - asprintf() error", list);
Might be useful to add an explicite debug log for a) using the prepared value b) re-calculating. Right now it uses Querying count of distinct domains in gravity database table vw_gravity for both situations if I understand the code correctly. (Might also help here: Pi-Hole goes offline for several minutes after adding entry to whitelist · Issue #3507 · pi-hole/pi-hole · GitHub )