Draft
Conversation
Collaborator
|
What are the performance implications of using this feature? Are there any online resources that discuss this? |
Owner
Author
|
@neektza https://blog.jooq.org/the-performance-of-various-to-many-nesting-algorithms/ . It's still N+1, but on the DB level, so no network roundtrip. TL;DR, it will depend on the size of the dataset. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements ability to embed relations under a column in Penkala queries. It is inspired by jOOQ's
multisetoperator and implemented in similar fashion.Problem
Penkala is a single query builder. It generates SQL which is then passed to JDBC, and then decomposed by Penkala's decomposition function (which transforms SQL rows into a tree structure). There are queries that are hard to express using only joins (for instance: get first 5 users and 5 latest articles for each of those users) which is where embedded relations come into play.
Example
(this example implements the same query as the one on the jOOQ blog)
Generated SQL
Embedded relations are converted to JSON, and we also pick up SQL types of all columns so we can coerce them during decomposition. Coercion is usually happening on the JDBC level, but since JSON has only a subset of types that can be returned from the query we will need to implement coercion in our codebase (with
com.verybigthings.penkala.decomposition/coerce-embedded-valuemultimethod).