You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
erDiagram
Product ||--o{ ParameterValue : "has zero or more"
ParameterValue ||--|| Parameter : "has exactly one"
Parameter ||--o| ParameterGroup : "has at most one"
Loading
... and the reverse relationship:
erDiagram
ParameterGroup ||--o{ Parameter : "has zero or more"
Parameter ||--o{ ParameterValue : "has zero or more"
ParameterValue ||--o{ Product : "has zero or more"
Loading
Then we could write this query to list all groups, parameters, and their values down to the set of exactly specified products in the following way:
This is quite cumbersome, since it's obvious that we need to repeat the filtering conditions from the leading `filterBy' clause. Moreover, the query is suboptimal because the similar filtering occurs repeatedly. The idea of this issue is to introduce a "placeholder" constraint that would allow us to reuse the results of the initial filtering, making the query both more readable and faster because we could just reuse intermediate results along the way:
This approach is similar to ANSI SQL [Common Table Expressions] (https://www.atlassian.com/data/sql/using-common-table-expressions) and allows to remember any intermediate result and use it in another place for additional filtering. It also allows to combine it with additional filters and to use AND, OR, NOT extensions.
When reusing the results, we would have to verify that the intermediate results match the expected entity type at a certain level - so that we don't combine resulting product primary keys with parameter primary keys and what not. This would lead to incorrect and chaotic results.
The text was updated successfully, but these errors were encountered:
First user impressions are that the concept is hard to grasp, although it's easy to implement from an engine point of view. It was pointed out to me by @lukashornych that there is already a way in GraphQL to reuse common fragments:
This is only client-side optimization, but as I realized it could be leveraged on the server side if we could automatically reuse results of constraints with the same hash within the same computation (nested computations). This could be implemented quite easily.
The exact same thing could be done programmatically even in Java, although the result query is complex and hard to read. So the idea will stay in the backlog, but we need more experience to design it properly.
Consider the following relationship:
... and the reverse relationship:
Then we could write this query to list all groups, parameters, and their values down to the set of exactly specified products in the following way:
This is quite cumbersome, since it's obvious that we need to repeat the filtering conditions from the leading `filterBy' clause. Moreover, the query is suboptimal because the similar filtering occurs repeatedly. The idea of this issue is to introduce a "placeholder" constraint that would allow us to reuse the results of the initial filtering, making the query both more readable and faster because we could just reuse intermediate results along the way:
This approach is similar to ANSI SQL [Common Table Expressions] (https://www.atlassian.com/data/sql/using-common-table-expressions) and allows to remember any intermediate result and use it in another place for additional filtering. It also allows to combine it with additional filters and to use AND, OR, NOT extensions.
When reusing the results, we would have to verify that the intermediate results match the expected entity type at a certain level - so that we don't combine resulting product primary keys with parameter primary keys and what not. This would lead to incorrect and chaotic results.
The text was updated successfully, but these errors were encountered: