[ 
https://issues.apache.org/jira/browse/OFBIZ-4041?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marc Morin updated OFBIZ-4041:
------------------------------

    Attachment: OFBIZ-4041.patch

Patch for implementation of Materialized views.  This implementation used a 
visitor pattern, on the ModelEntity (and related classes) so they are part of 
the patch.  Also, since entities are created by code, as opposed to by reading 
XML files, a number of getters and setters were added to the model objects. 

A new class, ModelMaterializedEntity is created when a view is read having 
materialized="true" property.   It creates an ECA for all the dependent 
entities used by the view.

There is NO checking on the usefulness or expense of the materialized views.  
It should also only be used on views where the pkey of the underlying entity is 
exposed as a field in the view, since this makes the ECA more efficient.

CheckDb will rebuild all materialized views since there is no way currently in 
OFBIZ to detect that the view's definition has changed.  In our implementation, 
we record an MD5 of the view as a comment on the table.... thereby detecting if 
we need to rebuild. That wasn't included at this time.

No ECA to prevent store/remove on the backing entity.

> Materialized views
> ------------------
>
>                 Key: OFBIZ-4041
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-4041
>             Project: OFBiz
>          Issue Type: New Feature
>          Components: framework
>    Affects Versions: Release Branch 10.04
>            Reporter: Marc Morin
>         Attachments: OFBIZ-4041.patch
>
>
> We make extensive use of view entities in our ofbiz application.  We have 
> noticed that when there is a large dataset and under some complex views, the 
> query performance was not the best (not a index issue, just complex joins, 
> etc...).
> With some commercial databases like Oracle, etc... we would have used 
> materialized view semantics available for these dbms, but we are using 
> PostgreSQL.
> So, we have extended the entity layer in Ofbiz to perform the 
> materialization.  This is pretty slick as all you need to do is the following:
> <view-entity name="myView" materialize="true">...</view-entity>
> and the system will do the following:
> - create a backing entity called "myView" that has the same fields as the view
> - backing entity has all the indexes inherited from the component entities
> - relations (fk,...) inherited from the component entities.
> - perform all the ECA actions automatically on all entities used in the view 
> (direct members and nested members if case of view on views). (This is an 
> eager update strategy only).
> So, the application doesn't change, it still accesses "myView", but now, it's 
> result is returned from the backing entity instead of the complex SQL 
> statement.
> We're pretty excited about this feature!!!  Really pushes Ofbiz framework to 
> next level and allows materialized views to be more broadly used on dbms that 
> don't naturally support it.
> We are prepared to contribute this feature back to the community if desired.  
> A note of caution about it though.... we have added a visitor pattern to the 
> model entities and this feature makes use of it.  It would need to come with 
> it.   

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to