openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: Entity generation is very time consuming
Date Thu, 14 Jul 2011 13:52:27 GMT
Just for giggles, what if you did something like this:

java.util.List<Object[]> datas =
emf.createEntityManager().createQuery("SELECT b.id, b.bezeichnung FROM Bp
b",Object[].class).getResultList();
java.util.List<BpSimpleDto> res = new ArrayList<BpSimpleDto>();

for(Object[] data : datas){
    res.add(new BpSimpleDto(data[0],data[1]));
}

On Thu, Jul 14, 2011 at 8:13 AM, M. Walter <marc.walter@sbb.ch> wrote:

> No problem. This is the regular query:
>
> [7/13/11 15:24:35:380 CEST] 00000016 Query         3   openjpa.Query:
> Trace:
> Executing query: SELECT b FROM Bp b
> [7/13/11 15:24:35:380 CEST] 00000016 jdbc_SQL      3   openjpa.jdbc.SQL:
> Trace: <t 1040137727, conn 1793682153> executing prepstmnt 969750989 SELECT
> t0.ID, t0.ROW_MUT_VERSION, t0.ROW_ERF_TSTAMP, t0.ROW_ERF_USER,
> t0.ROW_MUT_TSTAMP, t0.ROW_MUT_USER, t0.ABKUERZUNG, t0.BEZEICHNUNG,
> t0.BEZEICHNUNG_LANG, t0.BPUIC, t1.ID, t1.ROW_MUT_VERSION,
> t1.ROW_ERF_TSTAMP,
> t1.ROW_ERF_USER, t1.ROW_MUT_TSTAMP, t1.ROW_MUT_USER, t1.CHECK_URL,
> t1.FORMAT, t1.FTP_CLIENT_FACTORY, t1.INTERVALL, t1.NAME, t1.TYP,
> t1.VERZEICHNIS_ARCHIV, t1.VERZEICHNIS_DB, t1.VERZEICHNIS_IN,
> t0.FIKTIV_BP_TF, t0.GUELTIG_BIS, t0.GUELTIG_VON, t0.HALT_AUF_VERLANGEN_TF,
> t2.ID, t2.ROW_MUT_VERSION, t2.ROW_ERF_TSTAMP, t2.ROW_ERF_USER,
> t2.ROW_MUT_TSTAMP, t2.ROW_MUT_USER, t2.ABKUERZUNG, t2.ROW_GUELTIG_BIS,
> t2.ROW_GUELTIG_VON, t3.ID, t3.ROW_MUT_VERSION, t3.ROW_ERF_TSTAMP,
> t3.ROW_ERF_USER, t3.ROW_MUT_TSTAMP, t3.ROW_MUT_USER, t3.BESCHREIBUNG_DE,
> t3.BESCHREIBUNG_EN, t3.BESCHREIBUNG_FR, t3.BESCHREIBUNG_IT,
> t3.ROW_GUELTIG_BIS, t3.ROW_GUELTIG_VON, t3.TEXT_DE, t3.TEXT_EN, t3.TEXT_FR,
> t3.TEXT_IT, t2.UIC_LAND, t2.WAEHRUNG, t2.ZEITZONE, t0.PRIO, t0.REGION,
> t0.ROW_GUELTIG_BIS, t0.ROW_GUELTIG_VON, t0.UIC_BP, t0.UIC_KONTROLLZIFFER,
> t0.X_GEO, t0.X_SWISS_GRID, t0.Y_GEO, t0.Y_SWISS_GRID, t0.Z_GEO,
> t0.Z_SWISS_GRID FROM BP t0, DATENQUELLE t1, LAND t2, TEXT_SD t3 WHERE
> t0.DATENQUELLE_ID = t1.ID(+) AND t0.LAND_ID = t2.ID(+) AND t2.TEXT_SD_ID =
> t3.ID(+)
> [7/13/11 15:24:35:442 CEST] 00000016 jdbc_SQL      3   openjpa.jdbc.SQL:
> Trace: <t 1040137727, conn 1793682153> [62 ms] spent
> [7/13/11 15:24:58:849 CEST] 00000016 jdbc_JDBC     3   openjpa.jdbc.JDBC:
> Trace: <t 1040137727, conn 1793682153> [0 ms] close
>
>
> And this query reads two fields from a table using constructor expression:
>
> [7/14/11 10:50:41:361 CEST] 00000015 Query         3   openjpa.Query:
> Trace:
> Executing query: SELECT NEW
> xxx.xxxxxx.xxxxxx.common.dto.simple.BpSimpleDto(b.id, b.bezeichnung) FROM
> Bp
> b
> [7/14/11 10:50:41:361 CEST] 00000015 jdbc_SQL      3   openjpa.jdbc.SQL:
> Trace: <t 1133790100, conn 451943152> executing prepstmnt 455416613 SELECT
> t0.ID, t0.BEZEICHNUNG FROM BP t0
> [7/14/11 10:50:41:408 CEST] 00000015 jdbc_SQL      3   openjpa.jdbc.SQL:
> Trace: <t 1133790100, conn 451943152> [47 ms] spent
> [7/14/11 10:51:04:642 CEST] 00000015 jdbc_JDBC     3   openjpa.jdbc.JDBC:
> Trace: <t 1133790100, conn 451943152> [0 ms] close
>
> As you can see both the first and second query take 23 seconds to execute.
> There are exactly 59035 rows in the table.
>
> --
*Rick Curtis*

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message