You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Pascal Robert <pr...@druide.com> on 2018/01/10 12:34:49 UTC

Object not cached/SELECT on each access

Hi,

I’m trying to find out why it takes between 200 and 500 ms to convert an entity coming from FileMaker and commit the « new » entity to MySQL. Found out that every time I access a property of the fetched object, Cayenne does a SELECT query. Example:

   try(ResultBatchIterator<ContactsPrincipaux> batch = ObjectSelect.query(ContactsPrincipaux.class, null, tris).batchIterator(context, 100)) {
      for (List<ContactsPrincipaux> contactsPrincipaux: batch) {
        for (ContactsPrincipaux contactPrincipalFileMaker: contactsPrincipaux) {
          Utilisateur contactPrincipalMySQL = mysqlContext.newObject(Utilisateur.class);
          
          contactPrincipalMySQL.setNoFilemaker(contactPrincipalFileMaker.getKpCodeContact().longValue());

          LocalDateTime dateCreation = transformeDate(contactPrincipalFileMaker.getZCreationDate(), contactPrincipalFileMaker.getZCreationHeure());
          LocalDateTime dateModification = transformeDate(contactPrincipalFileMaker.getZModifDate(), contactPrincipalFileMaker.getZModifHeure());

That would generate 5 SELECT for the same object, because I’m called 5 properties on contactPrincipalFileMaker. The SELECT statements are exactly the same (same columns, same primary key). I was reading the guide, and looks like the object should not be refetched by default, so I don’t understand why it’s happening. 



Re: Object not cached/SELECT on each access

Posted by Pascal Robert <pr...@druide.com>.
> Le 10 janv. 2018 à 11:16, John Huss <jo...@gmail.com> a écrit :
> 
> Hard to say.
> 
> Is the shared cache enabled?  

I’m using the default settings.

> Is it sized big enough?

To hold everything? I don’t think so (+470 000 rows from FileMaker). 

> 
> Is the app under memory pressure when this is happening, or is it happening
> all the time?

All the time.

> 
> On Wed, Jan 10, 2018 at 6:35 AM Pascal Robert <pr...@druide.com> wrote:
> 
>> Hi,
>> 
>> I’m trying to find out why it takes between 200 and 500 ms to convert an
>> entity coming from FileMaker and commit the « new » entity to MySQL. Found
>> out that every time I access a property of the fetched object, Cayenne does
>> a SELECT query. Example:
>> 
>>   try(ResultBatchIterator<ContactsPrincipaux> batch =
>> ObjectSelect.query(ContactsPrincipaux.class, null,
>> tris).batchIterator(context, 100)) {
>>      for (List<ContactsPrincipaux> contactsPrincipaux: batch) {
>>        for (ContactsPrincipaux contactPrincipalFileMaker:
>> contactsPrincipaux) {
>>          Utilisateur contactPrincipalMySQL =
>> mysqlContext.newObject(Utilisateur.class);
>> 
>> 
>> contactPrincipalMySQL.setNoFilemaker(contactPrincipalFileMaker.getKpCodeContact().longValue());
>> 
>>          LocalDateTime dateCreation =
>> transformeDate(contactPrincipalFileMaker.getZCreationDate(),
>> contactPrincipalFileMaker.getZCreationHeure());
>>          LocalDateTime dateModification =
>> transformeDate(contactPrincipalFileMaker.getZModifDate(),
>> contactPrincipalFileMaker.getZModifHeure());
>> 
>> That would generate 5 SELECT for the same object, because I’m called 5
>> properties on contactPrincipalFileMaker. The SELECT statements are exactly
>> the same (same columns, same primary key). I was reading the guide, and
>> looks like the object should not be refetched by default, so I don’t
>> understand why it’s happening.
>> 
>> 
>> 


Re: Object not cached/SELECT on each access

Posted by John Huss <jo...@gmail.com>.
Hard to say.

Is the shared cache enabled?  Is it sized big enough?

Is the app under memory pressure when this is happening, or is it happening
all the time?

On Wed, Jan 10, 2018 at 6:35 AM Pascal Robert <pr...@druide.com> wrote:

> Hi,
>
> I’m trying to find out why it takes between 200 and 500 ms to convert an
> entity coming from FileMaker and commit the « new » entity to MySQL. Found
> out that every time I access a property of the fetched object, Cayenne does
> a SELECT query. Example:
>
>    try(ResultBatchIterator<ContactsPrincipaux> batch =
> ObjectSelect.query(ContactsPrincipaux.class, null,
> tris).batchIterator(context, 100)) {
>       for (List<ContactsPrincipaux> contactsPrincipaux: batch) {
>         for (ContactsPrincipaux contactPrincipalFileMaker:
> contactsPrincipaux) {
>           Utilisateur contactPrincipalMySQL =
> mysqlContext.newObject(Utilisateur.class);
>
>
> contactPrincipalMySQL.setNoFilemaker(contactPrincipalFileMaker.getKpCodeContact().longValue());
>
>           LocalDateTime dateCreation =
> transformeDate(contactPrincipalFileMaker.getZCreationDate(),
> contactPrincipalFileMaker.getZCreationHeure());
>           LocalDateTime dateModification =
> transformeDate(contactPrincipalFileMaker.getZModifDate(),
> contactPrincipalFileMaker.getZModifHeure());
>
> That would generate 5 SELECT for the same object, because I’m called 5
> properties on contactPrincipalFileMaker. The SELECT statements are exactly
> the same (same columns, same primary key). I was reading the guide, and
> looks like the object should not be refetched by default, so I don’t
> understand why it’s happening.
>
>
>