Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [materialized-view]

Defined like a view but holding persistent data like a table, Materialized Views are a feature of a number of RDBMSs including Oracle, DB2 and postgres. SQL Server has a similar feature called an Indexed View that is considered similar enough to come under this tag.

Filter by
Sorted by
Tagged with
1
vote
0answers
24 views

MSSQL - Lock escalation on partitioned indexed view

I'm using partitioned tables where I set LOCK_ESCALATION to AUTO to prevent lock escalation to table level, but keep it on partition level. On the top of that table I have indexed view which is ...
0
votes
0answers
57 views

How does Optimistic concurrency interact with pessimistic concurrency in MSSQL

In MSSQL / Azure SQL, with Snapshots allowed and Read Committed Snapshot Isolation enabled, i have an application that does not use snapshot transactions explicitly (using the default RCSI everywhere)....
2
votes
2answers
80 views

How to make Indexed Views work for SQLCLR?

In SQL Server, the indexed view is a hellscape of limitations. But I need one. I have a formatter SQLCLR function that creates a prettified version of a domain key - users want to be able to search ...
0
votes
0answers
26 views

Materialized view bigger than table it is based on?

I have a database that's ~130 GB and one table makes up for most of this (85 GB). Because this table holds a lot of duplicates, we have a materialized view which basically uses a window function to ...
4
votes
1answer
91 views

MSSQL - How to support aggregate pushdown on indexed view with SUM(decimal)

I have an indexed view with non-clustered columnstore index, e.g. CREATE VIEW [dbo].[SalesAggregated] with schemabinding AS SELECT BusinessDate, ItemId ,...
1
vote
1answer
32 views

Oracle Materialized View - Is it Safe to Use Only ROWID as Record Identifier?

this is a question related to Oracle 12c. I'm currently trying to create MVs as data sources for Golden Gate replication. We need fast refresh because We have to replicate 60,000 rows + at one time ...
6
votes
1answer
487 views

Why SQL does not use the indexed view?

I have the following version of SQL Server: Microsoft SQL Server 2014 (SP3) (KB4022619) - 12.0.6024.0 (X64) Enterprise Edition (64-bit) on Windows NT 6.3 (Build 9600: ) (Hypervisor) I created ...
1
vote
0answers
91 views

Do Hive Materialized Views respond to added partitions to source tables?

Hive Materialized Views support partitions, CREATE MATERIALIZED VIEW [IF NOT EXISTS] [db_name.]materialized_view_name [DISABLE REWRITE] [COMMENT materialized_view_comment] [PARTITIONED ON (...
1
vote
0answers
24 views

Azure SQL - Modifying Indexed Views without downtime

We have a SQL Azure database with a large indexed view that supports a website with high traffic during business hours. One of our goals from a DevOps perspective to be able to ship software (...
1
vote
1answer
34 views

Different results from select and from materialized view

select distinct on (p) coalesce(native_fcm_token, push_token) p from session where user_id = 2779 and ((push_token is not null) or (native_fcm_token is not null)) returns 27 rows refresh ...
1
vote
0answers
36 views

Cronjob to check when Oracle Materialized View was last updated?

I have two database users in my Oracle DB and want to create MV's in User B which get their data from User A through a database link. I plan to autorefresh the MV's every night but want to make sure ...
0
votes
0answers
47 views

Create indexed view with fluctuating data behind

I´ve heard about indexed-views in MSSQL which can increase the performance. My problem is that I want to create a view which joins round about 5 tables. The tables are constantly updated and are ...
0
votes
0answers
36 views

mysql run out of memory during mview refresh

I want to create mview from mysql to Oracle using DBLink via odbc driver with Linux 64 bit os. but due to large number of Records around 2.5 cr records it raise the error ERROR at line 1: ORA-28500: ...
0
votes
0answers
34 views

Is it possible to execute a postgresql function when any view is refreshed?

I want to alert my application that are utilizing views when the view is refreshed. Is this possible using PostgreSQL built-in functionality? If not are there any other approaches to tackle this?
0
votes
2answers
1k views

Materialized views Performance

Postgres’ docs note: While access to the data stored in a materialized view is often much faster than accessing the underlying tables directly or through a view, the data is not always current; ...
0
votes
0answers
15 views

Ιndexed view after replication

I am trying to find a smart (no redundunt dataflow) way to aggregate data on views/tables to be used from our reporting tools. One given is that the reporting database is different from the oltp one, ...
0
votes
1answer
76 views

How do I force a Nested Loop join on Materialized View and Table in Oracle 12c

There is a third party app which generates a high-cost query that has a join on multiple tables. I created a materialized view on some of the tables using the same join that is originated in the ...
0
votes
1answer
89 views

Getting ORA-32042 even though i can create the view in SQL Developer

I have a strange problem creating a materialized view using the code generated by the export wizard. I have created a materialized view and pasted following code into the sql query tab from the popup....
1
vote
2answers
641 views

Why are some views listed as Materialized in MySQL explain statements if Materialized views don't exist in MySQL?

Hopefully the question is self explanatory. I've read that Materialized views do not exist in MySQL, yet sometimes I see something like this in EXPLAIN Can somebody clear this up for me? What's ...
0
votes
1answer
237 views

Does CREATE/REFRESH MATERIALIZED VIEW in PostgreSQL use the parallel planner?

I am wondering whether CREATE (with data) or REFRESH MATERIALIZED VIEW uses the parallel planner? When I EXPLAIN ANALYZE the query by itself (any query with parallel potential works here) without ...
0
votes
1answer
205 views

oracle-mysql fast refresh materialized view

Is is possible to Create Fast refresh enabled Materialized view from MySQL to Oracle . i know steps for oracle to oracle Fast refresh enabled Materialized view. But now the scenario is need to ...
1
vote
0answers
247 views

What are the advantages of using a Materialized View directly on a table?

Recently, in enterprise's Oracle database, I have seen some materialized views that filter directly columns of table without adding aggregate fields and without calling custom functions. Example: ...
0
votes
1answer
454 views

Is using indexed view with no expand on standard edition a must?

I have recently read the text below in 70-762 Developing SQL Databases (p. 67): The first benefit of using an indexed view is that when you use it Enterprise Edition of SQL Server, it uses the ...
3
votes
1answer
387 views

Creating materialized view is very slow

I have quite a complex query in PostgreSQL 10.4 on Amazon RDS (3 joins, quite a few conditions). It takes from 1.5 to 6 seconds to perform a select. However, when I want to create a materialized view ...
1
vote
1answer
200 views

What is the proper procedure for fixing materialized view replication?

Oracle 10 Standard: I have a number of materialized views built on pre-built tables. These are fast refreshed from a remote database over a link from one master db. They've generally been working ...
0
votes
1answer
457 views

Create a materialized view on commit with PIVOT function

I'm trying to create a materialized view with on commit refresh while using a PIVOT on it's select. I have the following tables: Events: represents an event that the system process. It's like a ...
3
votes
0answers
107 views

Bloat on Materialized Views

The Postgres documentation says that materialized views with concurrent refreshes generate bloat as usual tables, because it executes deletes and inserts. For usual tables, there are some queries to ...
0
votes
1answer
662 views

Export Materialized View from postgresql as a table?

I have a materialized view I created in Postgresql. I was wondering is there a way to pg_dump the materialized view as if they were tables, so when I import them into another database it sees it as ...
-1
votes
1answer
212 views

Create or refresh materialized view [on hold]

How would you create new or otherwise refresh a materialized view in Postgres? I've tried something like this: CREATE OR REFRESH MATERIALIZED VIEW institution_mv AS SELECT entity_id, ...
1
vote
0answers
33 views

How to aggregate transactions to form a stateful view which can be updated efficiently?

How to aggregate transactions to form a stateful view which can be updated efficiently? For example how to turn the following transactions: CREATE TABLE txns_combined(from_party,to_party,price,qty,...
0
votes
1answer
366 views

Postgres 9.5 Materialized View from a table with jsonb columns

For the purpose of improving performance of queries on a rather large table (5M+ rows) containing jsonb columns, I would like to create materialized views with data derived from those columns. ...
4
votes
1answer
307 views

Convert columns into rows for use with indexed/materalized view

I'd like to convert columns into rows for a given SQL Server table. The table effectively is an audit table; it stores a given old and new value in separate columns for a given user attribute (e.g. ...
0
votes
1answer
64 views

SQL Server - materialised (indexed) view not working as expected

I've created a materialised view in SQL Server, but when selecting from it I get the same performances and the same execution plan than when I select from the same query not "materialised". The view ...
1
vote
0answers
626 views

Autorefresh for Postgres materialised view?

Is it possible to set an automatic refresh frequency for materialized views? Here's the situation, I have an important but relatively small (20 thousand row) table that's subject to constant updates (...
5
votes
1answer
356 views

What is a good way to parameterize a materialized view on Postgres?

Given for example a materialized view like this (Postgres 10.3): create materialized view my_view as select * from my_table where sell_date < '2018-03-01'; The sell_date comparison value ('...
0
votes
0answers
46 views

In-line TVF is using indexed views in a UNION - parameter should eliminate most of them, except it doesn't

I am using SQL Server 2016-SP1-CU8 Here is the code to setup my scenario: --1. Drop indexed views (in case of re-running IF OBJECT_ID('Widgets_1', 'V') IS NOT NULL DROP VIEW Widgets_1 IF ...
0
votes
1answer
72 views

SQL Indexed View for Datamart Reporting with Transactional Replication

Should Indexed Views be utilized/recommended as method to auto-generate DataMart Reporting tables? We have a Customer timeline of tables which can be simply joined on CustomerId in each tables. ...
3
votes
2answers
1k views

Postgres Materialized View Dramatically Increasing In Size

I have a production postgres 10 database. Every hour I run "refresh materialized view concurrently" on my materialized view to recalculate the values; only a few new rows get added each day. All the ...
1
vote
1answer
117 views

PostgreSQL drop view in case of unknown whether materialized or not

I'm trying to drop a view, of which I cannot assure whether it is a MATERIALIZED VIEW or a VIEW. DROP VIEW IF EXISTS myview; throws an error, if myview is a MATERIALIZED VIEW and vice versa. What I ...
10
votes
3answers
3k views

What happens if two process try to REFRESH MATERIALIZED VIEW CONCURRENTLY at the same time?

According to the docs: CONCURRENTLY Refresh the materialized view without locking out concurrent selects on the materialized view. (...) ... OTHER CONTENTS ... Even with this option ...
0
votes
1answer
635 views

Oracle - Foreign Key on non Unique - is materialized view the answer?

we have the following table to store texts in different languages: CREATE TABLE TXT ( TXTID VARCHAR2(10 BYTE) NOT NULL , LANGUAGE VARCHAR2(2 BYTE) DEFAULT 'DE' NOT NULL , STEXT VARCHAR2(10 BYTE) ...
1
vote
0answers
54 views

Combining two event tables into one postgres view

I have two tables, events and event_logs. The events table stores the theoretical data on a recurring event whereas the event_log stores specific information on a particular datetime. Event +-----...
0
votes
1answer
45 views

Multiple table constraint in oracle

A table of boxes, with a capacity column, and a table of items with columns box and size, and you want to enforce the constraint that an item can't be put in a box of capacity smaller than the item. ...
1
vote
0answers
119 views

Error creating aggregate materialized view

Trying to create an aggregate materialized view: CREATE MATERIALIZED VIEW MV_LLATTRDATA_MAX_VERSIONS NOLOGGING BUILD IMMEDIATE REFRESH FAST ON COMMIT ENABLE QUERY REWRITE AS ...
0
votes
1answer
101 views

FK to table with non-unique values via a on commit refreshing materialized view?

I would like to create a FK to a table without unique values. So I cannot create a simple FK. [to clarify, the parent table has duplicates - dont ask why, not in my control ] I tried creating a ...
2
votes
2answers
1k views

Can't create indexed view against table with masked columns

I am trying to create an index on a view that references a table with a masked column (SQL Server 2016). The masked column is not the only one in that table, and it's not used in the view. create ...
1
vote
3answers
10k views

Materialized view became INVALID and USER_MVIEWS.COMPILE_STATE becomes 'NEEDS_COMPILE'

I have an application which is getting data from Oracle(11.2.0.4) Materialized view, there is expected behaviour about materialized view will go INVALID when any DML action happens on the associated ...
6
votes
1answer
4k views

How to do an incremental refresh of a PostgreSQL Materialized View?

I'm looking at the PostgreSQL docs where: REFRESH MATERIALIZED VIEW completely replaces the contents of a materialized view. The old contents are discarded. However, since 9.5 I believe, there is ...
4
votes
1answer
1k views

Analyze needed after a refresh materialized view?

Are we supposed to run ANALYZE myview; on a PostgreSQL 9.6+ materialized view after running a REFRESH MATERIALIZED VIEW CONCURRENTLY myview;? Or is it useless (maybe index statistics are already ...
1
vote
2answers
5k views

Trigger to update a materialized view once after relevant transaction?

I'm using PostgreSQL 9.6. I have a materialized view to support full-text search across two tables, which I'll call posts and tags. The tables are infrequently updated and frequently searched. I'm ...