Posts

Showing posts with the label materialized view

OLTP and OLAP

Image
Introduction In Postgres , OLTP and OLAP are two completely different database system design philosophies serving distinct purposes. Postgres itself is an extremely powerful relational database management system (RDBMS). By default, it is highly optimized for OLTP  and thanks to its rich ecosystem of extensions, Postgres can also fully support OLAP workloads. Here is the detailed difference between these two concepts: OLTP Online Transaction Processing : focuses on fast, accurate and secure processing of a large number of continuous financial or operational transactions from end users. Data characteristics: Data changes constantly ( Insert, Update, Delete continuously). Query Pattern : Read/write statements acting on one or a few specific data rows (for example, finding info of a specific customer with WHERE id = 123 ). Advantages Data integrity ( ACID ): Postgres guarantees absolute transaction integrity without errors or data loss, thanks to its locking mechanisms and MVCC ...

Standard View and Materialized View

Image
Introduction View Also known as Standard View or Virtual Table , this is essentially just an SQL query statement saved under a specific name. It does not store any data on the disk, it only stores the definition (SQL code block) within the system. Every time you execute SELECT * FROM my_view , Postgres runs the underlying SQL definition of that View directly against the base tables. The data is always up to date, if the source tables change, the View immediately reflects those modifications. Performance depends entirely on the original SQL query, if the original query is complex involving multiple table JOIN operations or AGGREGATE calculations, the View will run slowly because Postgres must recompute everything from scratch upon every invocation. Materialized View This is a View but it physically stores data on the disk just like a regular table. It saves the entire result of the query onto the disk at the moment it is created or refreshed. When you execute SELECT * FROM my_mat_vie...