You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Postgres, a Materialized View is basically a cached copy of a query, and has a lot in common with views and tables. They are treated just like tables when querying, and just like views in that they have an underlying query that produced the data.
However, they are not showing up in the tbls documentation, because they are neither a view, nor a table, and the current information schema query doesn't include materialized views anyway (they are listed in the pg_catalog.pg_class table but not in information_schema.tables).
Current materialized views can be listed with the pg_catalog.pg_matviews view. The following version of the tableRows query adds in materialized views:
If we then update the view definition handling to use the pg_catalog.pg_get_viewdef() function (which works for both views and materialized views) the code can also handle MATERIALIZED VIEWs. Note: pg_get_viewdef() takes an OID, but currently the OID is stored as a string, this should really be a uint64!
As an aside: the same feature request could apply to Oracle and SQL Server, which also support materialized views. I just don't know how they treat these types in their system catalog and if tbls already handles them.
The text was updated successfully, but these errors were encountered:
I'm very new to Go, and I haven't been able to make this work locally yet, as I can't seem to make Go pass in the tableOid value as an integer, rather than as a string. So currently the above fails with a panic: runtime error: invalid memory address or nil pointer dereference segfault as PostgreSQL can't find the view definition when tableOid is a string rather than an integer.
In Postgres, a Materialized View is basically a cached copy of a query, and has a lot in common with views and tables. They are treated just like tables when querying, and just like views in that they have an underlying query that produced the data.
However, they are not showing up in the
tbls
documentation, because they are neither a view, nor a table, and the current information schema query doesn't include materialized views anyway (they are listed in thepg_catalog.pg_class
table but not ininformation_schema.tables
).Current materialized views can be listed with the
pg_catalog.pg_matviews
view. The following version of thetableRows
query adds in materialized views:If we then update the view definition handling to use the
pg_catalog.pg_get_viewdef()
function (which works for both views and materialized views) the code can also handle MATERIALIZED VIEWs. Note:pg_get_viewdef()
takes an OID, but currently the OID is stored as a string, this should really be auint64
!This is a rough sketch of how this could work:
As an aside: the same feature request could apply to Oracle and SQL Server, which also support materialized views. I just don't know how they treat these types in their system catalog and if
tbls
already handles them.The text was updated successfully, but these errors were encountered: