/
(Complex) Nested vs. (Simple) Separated Selectors

(Complex) Nested vs. (Simple) Separated Selectors

Consider the following selectors, with the result of the first two used as parameters in the third:

Facility[] fs1 = Facility:equals(active,”yes”);
Immrecord[] im2 = Immrecord:lessThan(lastvisitdate, Mez:today());
Children[] cs1 = and(
	relationshipIn(facility, fs1),
	relationshipIn(immrecord, im2)
);

We distinguish between complex and simple selectors as complex selectors consisting of multiple nested selectors. The following, therefor, is the complex selector version of the above snippet.

Children[] cs1 = and(
	relationshipIn(facility, Facility:equals(Active,”yes”)),
	relationshipIn(immrecord, Immrecord:lessThan(lastvisitdate, Mez:today()))
);

This complex selector is more performant, potentially far more so. The reason is given in Lesson 10 of the Beginner's Tutorial, section "A Note on Complex Selectors":

Whenever possible, a single complex selector should always be preferred above multiple simple selectors. This is due to the fact that Helium will automatically optimise the backing data base queries for selectors. Using complex selectors instead of multiple simple intermediate selectors might therefore provide a significant performance advantage.

Another example can be seen at the above link.

 

Related content

Overview DSL Reference
Overview DSL Reference
Read with this
Variable Depth Data Model Hierarchies
Variable Depth Data Model Hierarchies
More like this
Lesson 06: Relationships
Lesson 06: Relationships
Read with this
Querying Data
More like this
GeoserverWidget
Read with this
1.25 Release Notes
1.25 Release Notes
More like this