Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check if materialized view is populated

Tags:

postgresql

Using postgres 9.5.2 (python client)

Is there any way to check if a materialized view is populated using a query? One that does not raise a warning the view is not populated?

like image 322
Daniel Dubovski Avatar asked Dec 19 '22 11:12

Daniel Dubovski


1 Answers

The quick answer:

SELECT relispopulated FROM pg_class WHERE relname = '<the table name>';

You can find more details about the pg_class table in the documentation. According to that, the field relispopulated should be true for everything but some materialized views, and I infer from that and from the name of the field, that it will give you what you want.

like image 69
jmelesky Avatar answered Jan 02 '23 14:01

jmelesky