What are the vw_ databases for?

Hello,

I just took a look at the gravity.db and asked myself what the difference between vw_gravity and the gravity or domainlist and vw_white/blacklist tables is... Can somebody explain me the purpose of the additional tables?

Thank you!

They serve as virtual tables to deliver redundant information for domains. This is something you typically do to avoid duplicating the same content and - by this - to actually save a lot of disk memory.

Check out, e.g., the definition of the vw_gravity view after having read the tutorial @DanSchaper linked above:

Here you can see that we amend the table gravity by the property adlist.id taken from the adlist_by_group table, and furthermore show only enabled or unmanaged (adlist_by_group.group_id IS NULL) domains of the correct type.

This all just makes subsequent interaction with the database easier and there is one place where filters can be changed/updated when we decide to add some further functionality in a future version of Pi-hole.

1 Like

That was super helpful - thank you!

Of course I've already took a look in the documentation but it is not explained what the vw_ databases are for...

They are views: SQLite - Views - Tutorialspoint

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.