QueryPlan
(Created page with "QueryPlan is what we call the ability to statically analyze a viewmodel to know ahead of time what data it will use. QueryPlan is used to efficiently fetch the data for a vie...")
 
(Adding page to Category:TOC because it contains a TOC.)
 
(14 intermediate revisions by 4 users not shown)
Line 1: Line 1:
QueryPlan is what we call the ability to statically analyze a viewmodel to know ahead of time what data it will use.
QueryPlan is what we call the ability to statically analyze a ViewModel to know ahead of time what data it will use. QueryPlan is used to efficiently fetch the data for a view.


QueryPlan is used to efficiently fetch the data for a view.
Since views may shift what data they show (seekers or when base nesting on variables), the QueryPlan logic is active even after view creation - to make sure the slow-performing lazy fetch does not kick in.


Since views may shift what data they show (seekers or when base nesting on variables) the QueryPlan logic is active even after view creation - to make sure the slow performing lazy fetch does not kick in.
Lazy fetch is a strategy to fetch the object needed for an object locator just in time. This is practical but if every object would fetch itself with a roundtrip to the server, the application would not scale at all.


Lazy fetch is a strategy to fetch the object needed for a object locator just in time. This is practical but if every object would fetch itself with a roundtrip to server the application would not scale at all.
QueryPlan has multiple steps:
# Statically figure out the Hierarchy building expressions (the nestings). On this level, we only collect Class and Relation + the classes that expressions used the allinstances operator on
# Statically figure out what the other columns use (the non-nestings)
From these 2 steps, we have static information about what TYPE of information will - at one point or another - be used by the view - per hierarchy level.
 
QueryPlan places a subscription on all vCurrent variables for Nesting levels. Whenever a vCurrent variable is shifted, it may be an opportunity for QueryPlan to efficiently fetch data below this point.
 
This happens, for example, in seekers, when a user has a new list of objects and the selected object may be root to show details. In this case, QueryPlan will kick in and efficiently fetch such details for the selected object.
 
If your View is not a seeker in any form, the data is already fetched and QueryPlan should discover that no unseen objects are requested - and thus no fetch is needed.
 
=== Understanding the Query Planner ===
 
===== Static Plan =====
Right-click on the ViewModel main class and then select Extras and QueryPlan.   
 
That will place a text block in the clipboard with a report on what the QP tree sees.
[[File:QueryPlanStaticPlan.png|none|thumb|472x472px]]
 
===== Viewmodel scope and expressions =====
See [[Analyze ViewModel classes and expressions]] for more information.
 
===== QP data in turnkey when debugging =====
At the end of the [[Training:Development info in runtime|debug]] page, you can see the executed QP levels.
 
=== Debugging QueryPlan execution ===
You can see the QP log in the debugger. On the tab "Logging", turn on the PMapper to see QP log entries.


QueryPlan has multiple steps:
Usually, after turning on the log, set an object and pick the ViewModel you want to analyze in the tab "Result as root for ViewModel tree". The fetch of the ViewModel runs and you will get a log of how the QP fetches the ViewModel.
# Statically figure out Hierarcy building expressions (the nestings). On this level we only collect Class and Relation + the classes that expressions used the allinstances operator on
 
# Statically figure out what the other columns use (the non nestings)
Explanation of the log content:<blockquote>QPlap => in which process stage/lap the QP is</blockquote><blockquote>START Hierarchy => start of the QP's loading of ViewModel structure fetching links</blockquote><blockquote>QPlap START Columns => start of following single links</blockquote>'''Note:''' The XML persistence mapper doesn't use the multi-expression fetcher - it is a feature of the MDrivenServer.
From these 2 steps we have static information about what TYPE of information that will - at one point or another - be used by the view - per hierarcy level
 
=== Keywords ===
Query optimizer, Query planner, optimise, ViewModel optimiser
[[Category:View Model]]
{{Edited|July|12|2024}}
 
[[Category:TOC]]

Latest revision as of 14:13, 26 March 2024

QueryPlan is what we call the ability to statically analyze a ViewModel to know ahead of time what data it will use. QueryPlan is used to efficiently fetch the data for a view.

Since views may shift what data they show (seekers or when base nesting on variables), the QueryPlan logic is active even after view creation - to make sure the slow-performing lazy fetch does not kick in.

Lazy fetch is a strategy to fetch the object needed for an object locator just in time. This is practical but if every object would fetch itself with a roundtrip to the server, the application would not scale at all.

QueryPlan has multiple steps:

  1. Statically figure out the Hierarchy building expressions (the nestings). On this level, we only collect Class and Relation + the classes that expressions used the allinstances operator on
  2. Statically figure out what the other columns use (the non-nestings)

From these 2 steps, we have static information about what TYPE of information will - at one point or another - be used by the view - per hierarchy level.

QueryPlan places a subscription on all vCurrent variables for Nesting levels. Whenever a vCurrent variable is shifted, it may be an opportunity for QueryPlan to efficiently fetch data below this point.

This happens, for example, in seekers, when a user has a new list of objects and the selected object may be root to show details. In this case, QueryPlan will kick in and efficiently fetch such details for the selected object.

If your View is not a seeker in any form, the data is already fetched and QueryPlan should discover that no unseen objects are requested - and thus no fetch is needed.

Understanding the Query Planner

Static Plan

Right-click on the ViewModel main class and then select Extras and QueryPlan.

That will place a text block in the clipboard with a report on what the QP tree sees.

QueryPlanStaticPlan.png
Viewmodel scope and expressions

See Analyze ViewModel classes and expressions for more information.

QP data in turnkey when debugging

At the end of the debug page, you can see the executed QP levels.

Debugging QueryPlan execution

You can see the QP log in the debugger. On the tab "Logging", turn on the PMapper to see QP log entries.

Usually, after turning on the log, set an object and pick the ViewModel you want to analyze in the tab "Result as root for ViewModel tree". The fetch of the ViewModel runs and you will get a log of how the QP fetches the ViewModel.

Explanation of the log content:

QPlap => in which process stage/lap the QP is

START Hierarchy => start of the QP's loading of ViewModel structure fetching links

QPlap START Columns => start of following single links

Note: The XML persistence mapper doesn't use the multi-expression fetcher - it is a feature of the MDrivenServer.

Keywords

Query optimizer, Query planner, optimise, ViewModel optimiser

This page was edited 29 days ago on 03/26/2024. What links here