Terribly slow loading view for entity

Hi,

I takes ages to reload a view for a given entity. The delay taking between 5 and 10 secs for each entity instance is from my point of view unjustified. This is the code I use:

if (!PersistenceHelper.isNew(recibo)){
                    recibo = AppBeans.get(Persistence.class).getEntityManager().reload(recibo, "recibo-listado-recibos-view");
                }

And the view involved is like this:

Bear in mind that regarding the subobjects all views I am extending are base or local. I don’t understand why it may be taking so long… certainly Ids are huge… but I don’t know if that may suffice to cause such long retrieval latencies…

It is true that the object graph is big. However if loading it straight from db, the query retrieves results inmediately.

Any suggestions are greatly appreciated.

Regards,

Carlos.

Don’t know why the xml for the view didn’t publish:















































the xml for the view won’t show. I will upload the text…
view.xml (2.2 KB)

Hi,

First - code blocks should be surrounded by triple backticks for proper rendering by the forum engine:

Second - for query performance analysis you can enable eclipselink.sql logger:
https://doc.cuba-platform.com/manual-7.1/logging_useful_loggers.html

You will get all SQL statements with parameters and timings and then you will be able to understand where is the slow place.

Thanks Alex, I attached the view.xml piece but here you have it again:

After checking the log, the folowing view for a single entity produces 461 statements!
How can I focus things differently?

<view entity="test1_Recibo" name="recibo-listado-recibos-view" extends="_local">
        <property name="ordenanteRemesa" view="_minimal">
            <property name="definicionRemesa" view="_minimal">
                <property name="nombreRemesa"/>
                <property name="cuentaBancaria" view="_base"/>
                <property name="modoPresentacion"/>
            </property>
            <property name="remesa" view="_minimal"/>
        </property>
        <property name="utilitarioContratoInquilino" view="_minimal">
            <property name="fechaOcupacion"/>
            <property name="numeroContrato"/>
            <property name="tipoContrato"/>
            <property name="usoContrato"/>
            <property name="departamento" view="_base">
                <property name="ubicacion" view="_base"/>
            </property>
            <property name="inquilino" view="_base"/>
        </property>
        <property name="implementacionesConceptos" view="_base">
            <property name="conceptoRecibo" view="_minimal">
                <property name="concepto" view="_minimal">
                    <property name="tituloConcepto"/>
                    <property name="abreviacion"/>
                    <property name="adicionSustraccion"/>
                    <property name="ordenacion"/>
                </property>
            </property>
            <property name="overrideConcepto" view="_minimal">
                <property name="tituloConcepto"/>
                <property name="abreviacion"/>
                <property name="adicionSustraccion"/>
                <property name="ordenacion"/>
            </property>
            <property name="registroAplicacionesConceptosAdicionales" view="_minimal">
                <property name="conceptoAdicional" view="_base"/>
                <property name="nifDni"/>
                <property name="fechaValor"/>
                <property name="base"/>
                <property name="porcentaje"/>
                <property name="importeAplicado"/>
            </property>
            <property name="concepto" view="_minimal">
                <property name="tituloConcepto"/>
                <property name="abreviacion"/>
            </property
        </property>
    </view>

I believe this is not a good approach for loading entities for a report. A report needs to be fast, the longest 5 or 7 seconds, but this takes ages to load roughly 170 instances of this view, so need to address it differently… from your experience should I better load it via native sql for my JasperReport?

The point is that from time to time I need to do the same report but in preview mode (i.e. before the entities are stored in the db), so for certain tasks I need to have one version of the report for non stored instances, and another one in a native sql approach for stored entities in order no avoid long latencies.

Any comment is greatly appreciated.

Regards,

Carlos Conti.

Hi,

If you are not satisfied with JPQL data loading performance, you can rewrite data loading as native SQL query or even use a Groovy band that can perform several queries, mixing JPQL and SQL data loading.
Coding data loading into a Groovy band is the most flexible way.

Thanks Alex for your explanation. I think the most compatible way to pool all requirements is to select the data via sql. In the legacy system it was done via sql, and is therefore a clue that data needs to be gathered in the most efficient manner for it to be performing from the user perspective.

I will give it a change and come back on this issue.

Regards,

Carlos.