Poor data retrieval performance


I use Aurelius and XData.
I have 3 tables in relation to master detail such as tests / questions and their answers. and so on

I built with Aurelius several entities over these tables.

I try to preload in the client application (currently it is windows but I intend it to be an android application) an approximate number of 350 questions with their answers of approximately 350 x 5 records for the disconnected use of data.

This preload takes relatively long. About 1 minute.
Sql-urille results seem ok, have good execution plan.

The sql server runs a large number of sqls that probably make loading difficult.

I could write 3 sql to bring this data but the idea is to use the framework to do that.

I tried to remove LazyLoad but the loading time did not improve.

What would be the best strategy to load a number of entities with the related details?

What sections of the documentation should I read?

When you have a master-detail relationship in Aurelius, the kind of

TParent = class
  Children: TList<TChildren>;

Aurelius will always perform an addition SQL to retrieve the children of every parent you have. So if you have 350 parent records, and you want to get the children of all of them, you will get 350 SQL executed to get the children.

One way to get around it is simply retrieve all children at once, like

AllChildren := Manager.Find<TChildren>
  .{ some criteria }
  .CreateAlias('Parent', 'p')

Which is what you would do with an SQL statement: retrieve all children ordered by parent, and manipulate them according to your business logic - separating them by parent, for example, adding to in-memory lists, etc..

The many-valued association is intended to help with business logic of a few entities, like when you are editing an invoice and want to have the invoice items being edited together, saved together, etc..

If you want to manipulate a big number of entities, then use a different approach for better performance, like the above mentioned.

Indeed, if I get the list separately, it loads very quickly

I have only one parent selected and the list contains 350 items.

I don't quite understand why if I read the list from the server separately
fTestQuestionList: = DataService.XClient.List <TELEV_TEST_QESTION> (Format ('$ filter = (IDTEST eq% d) & $ orderby = ORD', [aIdElevTest]));
get the result in less than a second

and the same list declared as a multiple value association

[ManyValuedAssociation ([TAssociationProp.Required], [TCascadeType.SaveUpdate, TCascadeType.Merge], 'FIDTEST')]
[Orderby ("ORD")]

if I connect it to the same values
and I access it

it loads in 57 seconds

It's it just one parent, or many? You said an SQL is execute 350 times. Please consolidate your information or, even better, if possible, send us a minimal compilable test project reproduce the issue then we can better analyze it.