Skip to main content
Community site session details

Community site session details

Session Id :

Magical FetchMode property

Volodymyr Giginiak Profile Picture Volodymyr Giginiak
What does the FetchMode property on a query do? I will appreciate if someone will be able to give me very precise answer.
I know only implication of this parameter. It matters when exist/notexist joined datasources on the query are forming a tree - not a chain. If the tree of datasources is quite complex then your query has a very good chance not to work if FetchMode is not set to One2One.
To my knowledge it is related somehow to the way the kernel stores query datasources.
So, my rule of thumb is the following: if a query datasources form tree-like structure, FetchMode must be set to One2One everywhere exist/notexist join is used.

Example:
Query query;
QueryBuildDataSource qbdsInventTable;
QueryBuildDataSource qbdsInventItemGroup;
QueryBuildDataSource qbdsInventModelGroup;
;

query = new Query();
qbdsInventTable = query.addDataSource(tablenum(InventTable));

qbdsInventItemGroup = qbdsInventTable.addDataSource(tablenum(InventItemGroup));
qbdsInventItemGroup.relations(true);
qbdsInventItemGroup.joinMode(JoinMode::ExistsJoin);
qbdsInventItemGroup.fetchMode(QueryFetchMode::One2One);

qbdsInventModelGroup = qbdsInventTable.addDataSource(tablenum(InventModelGroup));
qbdsInventModelGroup.relations(true);
qbdsInventModelGroup.joinMode(JoinMode::NoExistsJoin);
qbdsInventModelGroup.fetchMode(QueryFetchMode::One2One);

This was originally posted here.

Comments

*This post is locked for comments