• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: most efficient way to fetch GIDs?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: most efficient way to fetch GIDs?


  • Subject: Re: most efficient way to fetch GIDs?
  • From: Stefan Gärtner via Webobjects-dev <email@hidden>
  • Date: Tue, 15 Jul 2025 05:44:57 +0000
  • Thread-topic: most efficient way to fetch GIDs?

Hello OC,

I would suggest turning the Collection of EOGlobal into primary keys, like this:

// turn global IDs into primary keys (assuming int here, adjust if needed)
var pks = globalIds.stream().map(g -> (int) ((EOKeyGlobalID)
g).keyValues()[0]).toList();

// create fetch spec with pre-petching relationships
var fetchSpec = new ERXFetchSpecification<SomeEntity>(SomeEntity.ENTITY_NAME,
null, null);
fetchSpec.setPrefetchingRelationshipKeyPaths(SomeEntity.SOME_RELATIONSHIP);

// fetch EOs in batches, only needed if there are many EOs
var batchIterator = new ERXFetchSpecificationBatchIterator<>(fetchSpec, new
NSArray<>(pks), ec, 1000);
while (batchIterator.hasNextBatch()) {
    var objects = batchIterator.nextBatch();
    System.out.println("> " + objects.size());
}

The last step using the batch iterator is only needed if you expect a lot of
EOs (thousands or even more). Otherwise just use a qualifier like
SomeEntity.ID.in(pks) with a regular fetch.

Best regards,
Stefan


Von: OCsite via Webobjects-dev <email@hidden>
Antworten an: OCsite <email@hidden>
Datum: Dienstag, 15. Juli 2025 um 03:35
An: ocs--- via Webobjects-dev <email@hidden>
Betreff: most efficient way to fetch GIDs?

Hi there,

do please forgive a stupid question, this is probably EOF 101, but I am not
quite sure of the proper answer.

I've got a Collection of global IDs (it might be any kind of a Collection, from
an NSArray to a Java Set). All the GIDs represent the same entity, if
important. And the collection is not recursive (contains just GIDs, never other
nested collections).

I'd like to turn it into a collection of EOs, as efficiently as possible,
preferably with at worst one DB round-trip (which needs to include also a
pre-fetch of a :1 relationship of those objects, if a fetch is needed and the
data can't be filled from snapshots).

What's the best way to do that? I've tried
ERXEOControlUtilities.convertGIDtoEO, but for one, it does not seem to properly
support diverse collections (well I could turn the collection myself into an
NSArray of course, if need be; but it would be sorta nicer not to have to do
that), and besides, it does not seem to support a relationship prefetch (or
perhaps I missed/did something wrong at my side, which is always quite
probable).

Currently I simply turn all the GIDs into faults, which works properly, but is
terribly slow when all those faults (and their relationship faults) get fired
one-by-one later.

Thanks for any suggestion!
OC

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: most efficient way to fetch GIDs?
      • From: Ondra Cada via Webobjects-dev <email@hidden>
References: 
 >most efficient way to fetch GIDs? (From: OCsite via Webobjects-dev <email@hidden>)

  • Prev by Date: most efficient way to fetch GIDs?
  • Next by Date: Re: most efficient way to fetch GIDs?
  • Previous by thread: most efficient way to fetch GIDs?
  • Next by thread: Re: most efficient way to fetch GIDs?
  • Index(es):
    • Date
    • Thread