Use number of distinct gravity domains as counted and stored by pihole -g itself. This drastically reduces the runtime of reload-lists.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2020-02-02 23:45:12 +01:00
parent 9a5a941315
commit 2e7e6231e7
+9 -1
View File
@@ -432,7 +432,15 @@ int gravityDB_count(const unsigned char list)
char *querystr = NULL;
// Build correct query string to be used depending on list to be read
if(asprintf(&querystr, "SELECT count(DISTINCT domain) FROM %s", tablename[list]) < 18)
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);
return false;