PostgreSQL materialized view process analysis

PostgreSQL materialized view process analysis

This article mainly introduces the process analysis of PostgreSQL materialized views. The article introduces it in great detail through sample code, which has certain reference learning value for everyone's study or work. Friends in need can refer to it.

1. Create a view

CREATE MATERIALIZED VIEW [ IF NOT EXISTS ] table_name
[ (column_name [, ...] ) ]
[ WITH ( storage_parameter [= value] [, ... ] ) ]
[ TABLESPACE tablespace_name ]
AS query
[ WITH [ NO ] DATA ]

2. Delete the view

DROP MATERIALIZED VIEW table_name

3. Create an index

CREATE INDEX idx_index_name ON table_name USING index(column);

4. Manually refresh the view

REFRESH MATERIALIZED VIEW [ CONCURRENTLY ] name
  [ WITH [ NO ] DATA ]

The creation mechanism of materialized views is the same as that of MySQL view tables. Relevant information is queried directly from the corresponding table. However, the query of materialized views is the same as that of ordinary tables. It is equivalent to a cache mechanism, storing complex query results in materialized views, but a refresh operation is required each time to update new data. It is suitable for requirements that are not particularly high for data real-time performance. The version is only available after PostgreSQL 9.3. When refreshing the view in version 9.3, query work cannot be performed. After version 9.4, adding the CONCURRENTLY parameter can support read-time queries, but indexes must be available and the refresh speed will be slower (time is exchanged for query locks). Incremental queries are not currently supported.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • PostgreSQL view modification operations
  • PostgreSQL Tutorial (XVI): Detailed Explanation of System Views
  • PostgreSQL implementation of subquery returning multiple rows
  • PostgreSQL database views and subquery operations

<<:  JavaScript Shorthand Tips

>>:  HTML+CSS+JavaScript to make a girlfriend version of scratch card (you will learn it once you see it)

Recommend

How to enable TLS and CA authentication in Docker

Table of contents 1. Generate a certificate 2. En...

Detailed explanation of the basic commands of Firewalld firewall in Centos7

1. Basics of Linux Firewall The Linux firewall sy...

JavaScript realizes magnifying glass special effects

The effect to be achieved: When the mouse is plac...

17 404 Pages You'll Want to Experience

How can we say that we should avoid 404? The reas...

A brief introduction to the simple use of CentOS7 firewall and open ports

Overview (official has more detailed description)...

Implementation of setting fixed IP when starting docker container

Network type after docker installation [root@insu...

Common naming rules for CSS classes and ids

Public name of the page: #wrapper - - The outer e...

Steps to install MySQL on Windows using a compressed archive file

Recently, I need to do a small verification exper...

Our thoughts on the UI engineer career

I have been depressed for a long time, why? Some t...

React tsx generates random verification code

React tsx generates a random verification code fo...

Docker sets up port mapping, but cannot access the solution

#docker ps check, all ports are mapped CONTAINER ...

Avoid abusing this to read data in data in Vue

Table of contents Preface 1. The process of using...

How to use ElementUI pagination component Pagination in Vue

The use of ElementUI paging component Pagination ...

Introduction to JWT Verification Using Nginx and Lua

Table of contents Preface Lua Script nignx.conf c...

Randomly generate an eight-digit discount code and save it to the MySQL database

Currently, many businesses are conducting promoti...