2

I have two tables: CITY (~50000 rows) and COUNTRY (~220 rows). THere is a task, to provide which city is in which country via VIEW? And if you are able to use materialized view, is it better? I wrote current query:

CREATE VIEW cc as
SELECT ct.NAME AS "country", c.NAME AS "cty"
FROM CITY c JOIN COUNTRY ct ON cnt.CODE=c.COUNTRY;

It gives me the information I need, but I didn't realize any difference bitween normal view and materialized one. Which is relevant?

nlimits
  • 103
  • 1
  • 12
  • 2
    i don't think it's a question `Which is better`, rather - which one is relevant ? – Caffeinated Nov 24 '14 at 20:09
  • View is a pure macro like thing.. Where-as Materialised view is like cached data of your sql. Refreshed at some rate.(user defined) – Maheswaran Ravisankar Nov 24 '14 at 20:09
  • Thanks @Coffee, corrected the question. – nlimits Nov 24 '14 at 20:10
  • 2
    @MaheswaranRavisankar I understood it from definition, but I mean in my case which is the optimal one. In my opinion there is no so much sense to use materialized one, because there is no many data in tables – nlimits Nov 24 '14 at 20:12

1 Answers1

5

A View is "just" an SQL statement that is executed when you want to see the contents of your view. It is not a table that actually exists in the database. It is, by implication, up-to-date whenever you read from the view.

A materialized view is an actual table in the database. It is created when you create it, and you have to maintain it if you want it updated.

They are different things. Better or worse depends on your requirements.

Ask613
  • 2,775
  • 1
  • 19
  • 27