sraoss / pgsql-ivm

IVM (Incremental View Maintenance) development for PostgreSQL
Other
127 stars 12 forks source link

Allow TRUNCATE on base tables #144

Closed yugo-n closed 2 years ago

yugo-n commented 2 years ago

If we don't have any outer-joins, the view can be truncated when a base table is truncated. Otherwise, if we have any outer-joins, a simple refresh is performed.

yugo-n commented 2 years ago

I added tests.

Also, I fixed the behavior when the view has aggregates without GROUP clause.

Aggregate views without a GROUP clause always have one row. Therefore, if a base table is truncated, the view will not be empty and will contain a row with NULL value (or 0 for count()). So, in this case, we refresh the view instead of truncating it.