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
36
votes
1answer
4k views

How do you create a view with SNAPSHOT_MATERIALIZATION in SQL Server 2017?

SQL Server 2017 has a couple new stored procedures: sp_refresh_single_snapshot_view – input param for @view_name nvarchar(261), @rgCode int sp_refresh_snapshot_views – input param for @rgCode int ...
1
vote
1answer
923 views

Nologging materialized view

I need to create a materialized view (MV) with auto refresh every hour. After I create it, a lot of redo logs are generated (10GB per hour). I think the solution is to recreate the MV in NOLOGGING ...
3
votes
1answer
1k views

How to create a TSVECTOR column in a materialized view?

I am trying to implement full text search in a materialized view (MV for brevity), and I read that it's not possible to alter the MV itself, which rules out these solutions: Adding a new column with ...
-3
votes
1answer
187 views

Optimizing an indexed view used for selects to also do updates

I have a materialized indexed view that returns ~2.6 million of the ~2.7 million rows in the table, causing the optimizer to mostly use clustered index scans. If I do an update on this view will it ...
1
vote
1answer
106 views

Why is an index I created not being used in a query execution?

Background: this question stemmed from another question I asked, so you can get additional DDL/indexes from there, if need be. I have a query inside an indexed view, like this: SELECT [a].[...
4
votes
1answer
536 views

Indexed View over multiple partitioned tables and ALTER TABLE SWITCH

Is it possible to have an indexed view that combines 2 partitioned tables and still use ALTER TABLE SWITCH to move data out of both base tables? I'm receiving the following error when trying this and ...
5
votes
1answer
1k views

Refresh Materialized View impact on the DB

Hi we are running an PostgreSQL 9.6 database in Amazon RDS under a m4.large(2cpu 8gb) and a provisioned IOPS of 1000. The use case is the following: We have a table with several million of registries (...
2
votes
3answers
1k views

A performance Issue when querying a big table using a PK/clustered index

To simplify the situation, I will only consider one large table... On a nightly basis a store will send all the new and changed data for one day for a large table to the head office. (this portion is ...
10
votes
1answer
459 views

Why does the READPAST hint cause indexed views to be ignored?

I am investigating using the READPAST hint to reduce resource locking in our application's financial subsystem. It seemed like a good way to go because financial transaction records are only ever ...
1
vote
1answer
3k views

Using NEXT clause to set periodic materilized view refresh in oracle and verifying refresh

I am not able to find the right documentation on setting specific timings for materialized view refresh for oracle. I read up the documentation and some examples there, however there is no definite ...
1
vote
1answer
465 views

Does a materialize view refresh in its creation?

I create a materialized view with the following cast function. It does not give me an error during creation although it exists an error. But refresh gives the error. CREATE MATERIALIZED VIEW ...
2
votes
0answers
387 views

PostgreSQL - REFRESH MATERIALIZED VIEW while pg_dump

(Version 9.3) Asking this after searching around without any solution: I create a simple materialized view (in practice, I have a few of them). I call pg_dump to backup the database. While pg_dump ...
3
votes
2answers
3k views

PostgreSQL 9.3.13, How do I refresh Materialised Views with different users?

[I think the root cause of this problem is me not understanding permissions and privileges...] So, to set the stage, the set up I have is a DB, call it MyDb. I have two users, spu1 and u1, spu1 is a ...
0
votes
1answer
1k views

Materialized View for SQL Server

I want to know if there is some thing similar to materialized view for Oracle in SQL Server . Any ideas ?
10
votes
1answer
8k views

Refresh a PostgreSQL materialized view automatically without using triggers

I created a materialized view named view_table_A on a foreign data wrapper table table_A. What I want is for the view to be automatically updated after every new insert in table_A. I tried to do this ...
5
votes
1answer
460 views

Why does a WHERE clause with an indexed, computed datetime column on an indexed view seek the clustered index on the original table

First, sorry for the long title. The setup I reduced the example to the minimum, to make it clearer, so there is no meaningful semantic anymore. DBMS: Azure SQL Database V12. Assume there is ...
1
vote
0answers
303 views

An Indexed View slows updates to a crawl. Is there a hint to work around it?

I experimented with creating an Indexed View. I finally had a case which (almost) met the criteria for one. All inner joins, very few non-deterministic functions (which were moved to an outer view) ...
0
votes
3answers
17k views

How to know when a refresh of a materialized view has been completed

After a specific event(e.g. someone add new data into the database via a GUI), I need to refresh a materialized view that aggregates some data and only after that refresh is complete I have to query ...
1
vote
1answer
224 views

Create FAST Materialised View in Oracle 10g with ROWID

I want to create FAST refresh the below Materialized view through rowID method. `CREATE MATERIALIZED VIEW XXARG_ACC_ANALYSIS REFRESH FAST ON DEMAND AS SELECT gjb.name "Batch_Name", gjs....
0
votes
1answer
3k views

Creating a Materialized view with fast refresh and on Demand option

create materialized view XXARG_GOKU AS select XDR.GLOBAL_ID XDR.PARTY_ID, XDR.EMAIL_ADDRESS, XDU.CITY_CODE, XDU.STD_CODE, XDU.PIN_CODE_SERIAL_NO from XXARG_DUMMY XDU, XXARG_DRAGON XDR where XDR....
4
votes
1answer
2k views

Snapshot too old from materialized view refresh job

This Oracle database has a DBMS_JOB that runs the following materialized view refresh script : dbms_refresh.refresh(ABCD.V_POSTAL_CODES); If I run it by hand, it's finebut if the job executes it a ...
1
vote
1answer
416 views

Postgres: Database architecture and materialized views

I have a database with a huge table, that gathers the ranking history of mobile applications. The table is quite big, around 120 Go. In order for my DB queries not to be too slow, I implemented ...
0
votes
1answer
210 views

Inheritance and performance in database [closed]

I have 3 table linked by an "inheritance" with Entity Framework. Sadly, I have poor performance with those query because I can't make any good index. Here is the tables : CREATE TABLE [dbo].[...
1
vote
1answer
2k views

Changing the WHAT column of DBA_JOBS

I am using a job to update a materialized view. I found that the job would lock itself if the exec dbms_refresh.refresh(''"<schema>"."<materialized_view_name>"''); was not committed and ...
-1
votes
1answer
2k views

Create materialized view no refresh from existing view with index

I've already got a working db view : CREATE OR REPLACE FORCE VIEW "USER_DATA_VIEW" ("APP_USER_ID", "FIRST_NAME", "LAST_NAME", "FULL_NAME", "LOCATION_ID", "LOCATION_NAME") AS SELECT U.APP_USER_ID, ...
3
votes
2answers
4k views

Oracle 12c - Create materialized view results in ORA-00942

I have a view that I can access through a database link as such: SQL> select count(*) from REMOTE_SCHEMA.REMOTE_VIEW@REMOTE_DB; COUNT(*) -------- 110 I can create and successfully query the ...
2
votes
1answer
149 views

T-SQL to check whether or not a indexed view can be created on tableX?

After applying my database changes on the test environment, the test team starts testing their processes, one of the things I get is a truncate table error because the table is used in an indexed ...
0
votes
1answer
97 views

Multiple Non-Indexed Views with INCLUDEs vs. Multiple Indexed Views in High Write Situations

When you want to encapsulate your T-SQL to select different subsets of data from the same base tables, is it more efficient to use plain views in conjunction with nonclustered indexes and INCLUDEs on ...
1
vote
0answers
381 views

Multiple UNIONs get slow. Indexing or materialized views?

Let me start by stating that my DBMS is PostgreSQL 9.4. I have a database with, say 30 tables. Each table has a mirror table with historical data, that is the same columns and some timestamps. To ...
0
votes
2answers
208 views

Database Design: Should I use a Materialized View

I am designing a database based off of the NBA stats website (http://stats.nba.com/player/#!/201939/?p=stephen-curry) If you go to the link posted on the player's stat, you will notice that the ...
1
vote
0answers
897 views

Oracle 12c fast refreshing nested materialized view problems

I have a couple of nested materialized views that fast refresh. They worked fine in Oracle 11g but since upgrading to Oracle 12c (12.1.0.2.0 on Solaris) I am occasionally getting duplicate rows (the ...
3
votes
1answer
840 views

What indexed view capabilities does Azure SQL Database have?

Does Azure SQL Database support indexed views? Does it support automatic indexed view matching without NOEXPAND? Does the answer depend on the pricing tier? I was unable to find definitive answers to ...
0
votes
1answer
227 views

On a single table, how is an indexed view different from a non clustered index?

Assuming that no joins are involved, and the PK of the view (the UNIQUE Clustered Index) is the same as that of the base table, is there a difference between how a nonclustered index (NCL) and an ...
2
votes
0answers
196 views

Shouldn't DISCARD PLANS re-evaluate every function definition in postgres?

Hi have a set of functions that take a row of a table (let's call it bookings) as input parameters. Some of these functions call other functions, and they are used to calculate a materialized view. ...
1
vote
1answer
294 views

Group by's in materialized views and query planning [duplicate]

In part out of curiosity, I wondered if I could use an indexed (materialized) view to speed up a count query on some base table. The query is something like SELECT COUNT(*) FROM BaseTable WHERE Slot ...
1
vote
1answer
40 views

Data Replication in Oracle

I have a table on master site which only allow insert operation. I want to replicate the rows which are inserted recently so, need something which can track the last record replicated into the local ...
3
votes
1answer
806 views

Renaming a column in a materialized view with an unknown name

I have a materialized view with an unknown column name, and I need to give that column a name. I can't just recreate the view because it took a long time to create. dba=# \d temp_name_relationships; ...
2
votes
1answer
2k views

Create Materialized View from foreign table

I'd like to create a simple materialized view from a table which lies in a different database. The two databases are on the same server. What do I have to add to make the query access the foreign ...
1
vote
1answer
1k views

pgAdmin crashes or freezes when big MATERIALIZED VIEWs are refreshing

I'm using pgAdmin III v1.22.1 on Windows 7 to connect to a PostgreSQL server version 9.4.8 on Red Hat. We have scripts to REFRESH MATERIALIZED VIEWS during the night. When they are refreshing, I can'...
2
votes
0answers
2k views

Postgres: How to log materialized view refresh

I would like to keep a record of when various Postgres materialised views are refreshed. As far as I can see there are no built in logs. The next obvious choice is to create a trigger, however it ...
1
vote
0answers
471 views

Trying to find a MIN() workaround for an indexed view

I'm trying to speed up a Azure V12 SQL Server query using indexed views. I have one slow element, which I think is due to the use of GUIDs for the particular comparison column. The GUID can be mapped ...
1
vote
1answer
248 views

Include scripts for Indexes on Alter Views

After a Developer altered an Indexed View to add a comment, the clustered index that was created on it was dropped with no warning. This caused a failure as there are a couple of procedures that have ...
2
votes
0answers
495 views

parallel pg_restore with materialized views

I am trying to restore a database that includes some materialized views. I am migrating from a standalone postgres installation to RDS. To troubleshoot the restore process, I have split the restore ...
0
votes
1answer
289 views

Can there be situations where using (noexpand) on an indexed view is undesirable?

From the past experience using the schema bound and indexed view in a query with (noexpand) hint usually dramatically improves performance if the view is designed well. Apparently using the indexed ...
0
votes
2answers
201 views

Database view listing distinct days

I have a list of sensors of many machines, that stores on a second base (i.e., 86400 records each day for each machine). One of the many columns is the datetime of the value (that can also be stored ...
1
vote
2answers
111 views

Is there a way to do the following query with joins instead of a sub query?

I am using SQL Server 2014 and I want to eliminate having to use the following sub query so I can create an indexed view. The only thing similar to my problem is the greatest-n-per-group queries but ...
3
votes
1answer
113 views

Most efficient way of caching queries / processed data

I have doubts on database design. I'm trying to know if there is a way to increase query performance, and the easiest way for me to explain my doubt is with a small example. I have a news website ...
1
vote
1answer
1k views

PostgreSQL conditional join and value distribution with materialized view

So I essentially have two tables in a database. One which is the base table of all of our media data, and another that has potential override data for spend. Not everything in the display table will ...
1
vote
0answers
117 views

Query with join to a table on a different database need an index

I'm creating a query that one of its joins is made to a table from a different database. The query analyzer is suggesting the creation of an index, however I don't have permission to add objects to ...
1
vote
0answers
830 views

Update column type when materialized views depend on the column?

I'm working in Postgres 9.4. I want to alter the type of a column in a table: ALTER TABLE mytable ALTER COLUMN quantity TYPE integer; But I get this: ERROR: cannot alter type of a column used by a ...