Skip to content

findByIri/find Cartesian-products independent multi-valued properties in one BGP #175

Description

@ddeboer

Summary

When a schema has more than one independent multi-valued (@array) property, the query generated for findByIri/find places them all as OPTIONALs in a single BGP. The solution set becomes the Cartesian product of those properties' values. The parsed entity is correct, but on a store that does not deduplicate CONSTRUCT output (e.g. ad-freiburg/qlever#2062) the product is materialised on the wire, so the response grows as the product of the cardinalities instead of their sum.

Reproduction

A schema with three independent multi-valued properties (VoID here, but the shape is generic):

const Summary = {
  "@type": "http://rdfs.org/ns/void#Dataset",
  propertyPartition: { "@id": ".../propertyPartition", "@array": true, "@optional": true,
    "@schema": { property: { "@id": ".../property" }, entities: { "@id": ".../entities" } } },
  vocabulary: { "@id": ".../vocabulary", "@array": true, "@optional": true },
  dataDump:   { "@id": ".../dataDump",   "@array": true, "@optional": true },
};
await createLens(Summary, { sources: [endpoint] }).findByIri(iri);

On a real entity with 273 property partitions × 10 vocabularies, QLever returned ~3.2 MB / ~11k triples, of which only ~175 KB / ~820 are distinct — a ~13× inflation and ~10× slower to fetch/parse.

Workaround

Hand-write a CONSTRUCT for lens.query() giving each independent multi-valued property its own UNION branch. Same parsed result, ~13× smaller wire.

Possible directions (deferring to you on the generator)

  • Emit each independent multi-valued property in its own UNION branch (single-valued ones stay grouped), so results are proportional to sum(cardinalities) not product(cardinalities).
  • Or fetch each multi-valued property separately and merge client-side.

Happy to help if a direction is chosen.

Environment

  • ldkit 2.7.1; backing store QLever (does not deduplicate CONSTRUCT output).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions