Real time, fast update of materialized views
In this blog entry I have introduced the ongoing project: Incremental View Maintenance (IVM), which allows to real time, fast update of materialized views. Since the bolg, IVM now can handle outer joins and self joins. The out come of the project is in public in a form of set of patches against git master branch of PostgreSQL. Also a GitHub repository for this project is in public as well.
Docker image for IVM
So skilled PostgreSQL developers can test IVM today. However it's not that easy for people who do not regularly compile and build PostgreSQL and IVM from source code. Fortunately one of IVM developers "Yugo Nagata" comes up and starts to provide complete docker image of IVM. I am going to demonstrate how to use it step by step.
# Run psql to run pgbench
docker run -it --rm --link pgsql-ivm yugonagata/postgresql-ivm pgbench -i -h pgsql-ivm -U postgres test
# Run psql to try IVM
docker run -it --rm --link pgsql-ivm yugonagata/postgresql-ivm psql -h pgsql-ivm -U postgres test
# Create a materialized view "mv1" for query "select count(*) from pgbench_accounts.
# Note that "pgbench_accounts" was created by pgbench
test=# create incremental materialized view mv1 as select count(*) from pgbench_accounts;
SELECT 1
# select the result from the view
test=# select * from mv1;
count
--------
100000
(1 row)
# Start a transaction
test=# begin;
BEGIN
# delete 1 row from pgbench_accounts table
test=*# delete from pgbench_accounts where aid = 1;
DELETE 1
# Check to see if mv1 reflects the deletion
test=*# select * from mv1;
count
-------
99999
(1 row)
# Abort the transaction
test=*# abort;
ROLLBACK
# The deletion was cancelled in mv1 as well
test=# select * from mv1;
count
--------
100000
(1 row)
Summary
No comments:
Post a Comment