You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Nicolas Malin (JIRA)" <ji...@apache.org> on 2018/08/12 08:44:00 UTC

[jira] [Comment Edited] (OFBIZ-10514) Refactoring ContactMechWorker.get[Entity]ContactMechValueMaps

    [ https://issues.apache.org/jira/browse/OFBIZ-10514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16577459#comment-16577459 ] 

Nicolas Malin edited comment on OFBIZ-10514 at 8/12/18 8:43 AM:
----------------------------------------------------------------

I used EntityUtil.filterByDate after the query to ensure that the cache will be use because if you create a cache result with a now on parameters, you never reuse your cache.

But after check how the EntityQuery works with filterByDate, It use the same logic
{code:java}
    private List<GenericValue> query(EntityFindOptions efo) throws GenericEntityException {
        EntityFindOptions findOptions = null;
        if (efo == null) {
            findOptions = makeEntityFindOptions();
        } else {
            findOptions = efo;
        }
        List<GenericValue> result = null;
        if (dynamicViewEntity == null) {
            result = delegator.findList(entityName, makeWhereCondition(useCache), fieldsToSelect, orderBy, findOptions, useCache);
        } else {
            try (EntityListIterator it = queryIterator()) { 
                result = it.getCompleteList();
            }
        }
        if (filterByDate && useCache) {
            return EntityUtil.filterByCondition(result, this.makeDateCondition());
        }
        return result;
{code}
So if you use cache and you filter by date, you run the filter after the query :)
 Nice, I will update my patch


was (Author: soledad):
I used EntityUtil.filterByDate after the query to ensure that the cache will be use because if you create a cache result with a now on parameters, you never reuse your cache.

But after check how the EntityQuery works with filterByDate, It use the same logic 
{code}
    private List<GenericValue> query(EntityFindOptions efo) throws GenericEntityException {
        EntityFindOptions findOptions = null;
        if (efo == null) {
            findOptions = makeEntityFindOptions();
        } else {
            findOptions = efo;
        }
        List<GenericValue> result = null;
        if (dynamicViewEntity == null) {
            result = delegator.findList(entityName, makeWhereCondition(useCache), fieldsToSelect, orderBy, findOptions, useCache);
        } else {
            try (EntityListIterator it = queryIterator()) { 
                result = it.getCompleteList();
            }
        }
        if (filterByDate && useCache) {
            return EntityUtil.filterByCondition(result, this.makeDateCondition());
        }
        return result;
{code}
So if you use cache and you filter by date, you run the filter after the query :)
Nice, I will update I patch

> Refactoring ContactMechWorker.get[Entity]ContactMechValueMaps
> -------------------------------------------------------------
>
>                 Key: OFBIZ-10514
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-10514
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: party
>            Reporter: Nicolas Malin
>            Assignee: Nicolas Malin
>            Priority: Major
>         Attachments: OFBIZ-10514.patch
>
>
> ContactMechWorker.get[Entity]ContactMechValueMaps are old historic functions that resolve all contact mech context related to an Entity (Party, Facility, Order, WorkEffort).
> The problem that they create too many db call during their execution that decrease OFBiz performance when the contactMech history grow.
> On customer site I realized a new adaptation (oriented and not generic at all) and control the performance issue with a unit test :
> {code:java}
> public void testContactMechSearch() throws Exception {
>         UtilTimer timer = new UtilTimer("test contactmech", true, true);
>         timer.startTimer();
>         List<Map<String, Object>> cmwPostalAdress = ContactMechWorker.getPartyContactMechValueMaps(delegator, "10375", false, "POSTAL_ADDRESS");
>         timer.timerString("PA cmw " + cmwPostalAdress.size());
>         List<Map<String, Object>> cmwTelecomNumber = ContactMechWorker.getPartyContactMechValueMaps(delegator, "10375", false, "TELECOM_NUMBER");
>         timer.timerString("TN cmw " + cmwTelecomNumber.size());
>         List<Map<String, Object>> cmwEmail = ContactMechWorker.getPartyContactMechValueMaps(delegator, "10375", false, "EMAIL_ADDRESS");
>         timer.timerString("E cmw " + cmwEmail.size());
>         List<Map<String, Object>> epwPostalAdress =  CustomPartyWorker.getPartyContactMechValueMaps(delegator, "10375", false, "POSTAL_ADDRESS", null);
>         timer.timerString("PA cpw " + epwPostalAdress.size());
>         List<Map<String, Object>> epwTelecomNumber = CustomPartyWorker.getPartyContactMechValueMaps(delegator, "10375", false, "TELECOM_NUMBER", null);
>         timer.timerString("TN cpw " + epwTelecomNumber.size());
>         List<Map<String, Object>> epwEmail = CustomPartyWorker.getPartyContactMechValueMaps(delegator, "10375", false, "EMAIL_ADDRESS", null);
>         timer.timerString("E cpw " + epwEmail.size());
> }
> {code}
> The partyId "10375" is linked with more tha 600 contactMechs on my local site db. And the test excecution give :
> {code:java}
> With ContactMechWorker
>      [java] [[PA cmw 2- total:....,since last(Begin):33.707]] - 'test contactmech'
>      [java] [[TN cmw 2- total:....,since last(PA cmw 2):33.837]] - 'test contactmech'
>      [java] [[E cmw 1- total:1..,since last(TN cmw 2):33.115]] - 'test contactmech'
> With CustomPartyWorker
>      [java] [[PA epw 2- total:...,since last(E cmw 1):0.53]] - 'test contactmech'
>      [java] [[TN epw 2- total:...,since last(PA epw 2):0.588]] - 'test contactmech'
>      [java] [[E epw 1- total:...,since last(TN epw 2):0.631]] - 'test contactmech'
> {code}
> total ~100s for ContactMechWorker and ~1.5s for CustomPartyWorker
> Difference come that CustomPartyWorker works on a view entity gathering the data and populating GenericValue  with makeValue (using the data within the view) instead of creating new getRelated db access.
> I will implement this idea on generic context to improve these functions  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)