Обсуждение: View consistency
Hello! Im using several views for the Usermanagment of a database. My question is: How does postgres keep the views consistent to the according tables( if the original table has been changed)? Is there a Rule? and how is the Rule invoked. With ON DELETE UPDATE INSERT of the original table? I didnt found any Rule in pg_rules. There should be a rule, because I cannot imagine another way wich tells the view that the table has been changed. The problem is: If updating the view takes too much time after every little manipulation, I couldnt use views for usermanagement because of performance problems. Any hints and facts? Thanks in advance David
Вложения
"David M. Richter" <d.richter@dkfz.de> writes: > How does postgres keep the views consistent to the according tables( if > the original table has been changed)? It doesn't have to; views are not materialized in Postgres. A view is just a rewrite rule, or macro. regards, tom lane
On Thu, 1 Nov 2001, David M. Richter wrote: > Hello! > > Im using several views for the Usermanagment of a database. > My question is: > > How does postgres keep the views consistent to the according tables( if > the original table has been changed)? AFAIK it's a select rule on the view that rewrites into the view expression. Nothing keeps it consistent because it's effectively just a macro for the view expression.
"David M. Richter" <d.richter@dkfz-heidelberg.de> writes: > Select name from patient_view; > is in reality: > Select name from (select ...,...,... from basic where xxx=yyy); > Is that right? Yup. The rule rewriter just substitutes the view definition as a subselect. regards, tom lane
Hi, So every time when I 'll use the view, the constraint over the basic table will be revalidated. Select name from patient_view; is in reality: Select name from (select ...,...,... from basic where xxx=yyy); Is that right? DAvid
Вложения
Hi, Thanks, but what I am concerning is the performance. In my database are some tables bigger than 6 Millions of rows. If one row has been changed in the normal table, so the rule will be invoked and the view will be kept in consistance. But this will take some time, isn't it? I cannot simulate that case with my database, because Im still developing. So i have to know: Where is the rule or the macro stored? How could I disable it? Perhaps I could do a reinit of the view not after any Select, but after any transaction. But I dont know that rule or macro! How can I get some information about the rule (wich was automatically generated by creating the view)? Thanks for Your hints DAvid --------------------------------------------------------------- "David M. Richter" <d.richter@dkfz.de> writes: > How does postgres keep the views consistent to the according tables( if > the original table has been changed)? It doesn't have to; views are not materialized in Postgres. A view is just a rewrite rule, or macro. regards, tom lane