On Apr 1, 9:20 pm, Yarko Tymciurak <yark...@gmail.com> wrote:
> > http://www.postgresql.org/docs/8.3/interactive/sql-createrule.html
>
> and looking at this, it seems fairly straight forward:

Yes it does. The manual threw me when it said that "*Currently* views
are read only" but that "you can get the *effect* of an updatable view
by creating rules" -- sounded to me like hack I didn't want to get
into. ;) Reading more about rules in PostgreSQL, views are actually
implemented using rules so using rules to add insert/update/delete
behavior is the completely natural/blessed way to do it. Performance-
wise, queries I ran using the writable views seemed just as fast as
queries using the underlying tables. Running 20K updates on a view
sometimes took twice as long as updates on the table, but that's
probably more related to me testing on a laptop. Thanks for pushing me
to explore this more.

> if your view is just the table, with a field re-named to 'id' then this
> seems simple;
> Can you try the pattern shown by example in
> http://developer.postgresql.org/pgdocs/postgres/rules-update.html
> ...
> Let us know if this works.

It works! I was skeptical but I'm feeling pleasantly surprised. The
insert, update, and delete rules will be a bit t-e-d-i-o-u-s to write
(especially with lots of tables). Any on-the-fly tables you might
create (e.g., cached search results) will also need corresponding
views and rules created on-the-fly (at least if you need to join
against them). But  beyond the extra views and rules, legacy
PostgreSQL databases can be used with the DAL this way.

--David

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to