JavaBlog.fr / Java.lu Documentum,DQL DCTM Documentum : Use Of Hint ROW_BASED, Filtering and Count

Documentum : Use Of Hint ROW_BASED, Filtering and Count

Hello,

In this post, I would like to underline the use of the famous hint ROW_BASED in particular how the Content Server returns and filters the results of a DQL query.
 
A little theory
ROW_BASED – EMC® Documentum® Content Server Version 7.2 – DQL Reference
The ROW_BASED hint changes both the way query results are returned and the syntax rules for the query itself. The ROW_BASED hint forces Content Server to returns query results in a row format, as opposed to an object-based format. The difference is most readily apparent if the query selects values from a repeating property.
In an object-based format, the server returns all selected repeating values for a particular object in one query result object. In a row-based format, the server returns each selected repeating property value in a separate query result object.

 
 
Effects on returned results
For example, by default the following query returns results in an object-based format:

1SELECT r_object_id, title, authors FROM dm_document WHERE subject='new_book_proposal';
2....
3------------------------------------------------------------
4r_object_id | title | authors
5------------------------------------------------------------
6090000015973a2fc | Our Life and Times | Jennie Doe Carol Jones Hortense Smith
70900000123ac12f6 | Life of an Amoeba | James Does Jules Doe

This query returns the authors values as a list of authors in one query result object for each returned object. Each row in the table represents one query result object and each column is one property in the query result objects. There is one query result object (one row) for each object returned by the query.
 
Now, add the ROW_BASED hint to the query:

01SELECT r_object_id,title,authors FROM dm_document WHERE subject='new_book_proposal' ENABLE(ROW_BASED);
02....
03------------------------------------------------------------
04r_object_id | title | authors
05------------------------------------------------------------
06090000015973a2fc | Our Life and Times | Jennie Doe
07090000015973a2fc | Our Life and Times | Carol Jones
08090000015973a2fc | Our Life and Times | Hortense Smith
090900000123ac12f6 | Life of an Amoeba | James Does
100900000123ac12f6 | Life of an Amoeba | Jules Doe

There is one query result object (one row) for each repeating property value returned.
The returned repeating property values for each object are not aggregated into one result object.
 
 
Filtering of returned results
For example, by default the following query returns the number of authors for the targeted document:

01SELECT mydoc1.r_object_id, mydoc1.authors
02FROM dm_document mydoc1 where
03r_object_id = '0900000123ac12f6'
04and any mydoc1.authors IN('James Does');
05...
06------------------------------------------------------------
07r_object_id | authors
08------------------------------------------------------------
090900000123ac12f6 | James Does, Jules Doe
10 
11 
12SELECT mydoc1.r_object_id, count(mydoc1.authors)
13FROM dm_document mydoc1 where
14r_object_id = '0900000123ac12f6'
15and any mydoc1.authors IN('James Does')
16GROUP by mydoc1.r_object_id;
17...
18------------------------------------------------------------
19r_object_id | count(authors)
20------------------------------------------------------------
210900000123ac12f6 | 2

 
Now, add the ROW_BASED hint to the query:

01SELECT mydoc1.r_object_id, mydoc1.authors
02FROM dm_document mydoc1 where
03r_object_id = '0900000123ac12f6'
04and any mydoc1.authors IN('James Does')
05ENABLE (ROW_BASED);
06...
07------------------------------------------------------------
08r_object_id | authors
09------------------------------------------------------------
100900000123ac12f6 | James Does
11 
12 
13SELECT mydoc1.r_object_id, count(mydoc1.authors)
14FROM dm_document mydoc1 where r_object_id = '0900000123ac12f6'
15and any mydoc1.authors IN('James Does')
16GROUP by mydoc1.r_object_id
17ENABLE (ROW_BASED);
18...
19------------------------------------------------------------
20r_object_id | count(authors)
21------------------------------------------------------------
220900000123ac12f6 | 1

These queries return the authors values as a list of authors in one query result object (one row) for each repeating property value returned AND keep only the returned repeating property values corresponding to the filter. So it is necessary to be very careful when the use of ROW_BASED hint and processing of returned repeating property values.
 
 
So, in order to process “correctly” the returned repeating property values with use of ROW_BASED hint, a possible solution is to move the filter on repeating attribute from main query into a sub-query:

01SELECT mydoc1.r_object_id, count(mydoc1.authors)
02FROM dm_document mydoc1 where
03mydoc1.r_object_id = '0900000123ac12f6'
04and mydoc1.r_object_id IN(select r_object_id from dm_document mydoc2 where any mydoc2.authors IN('James Does'))
05GROUP by mydoc1.r_object_id
06ENABLE (ROW_BASED);
07...
08------------------------------------------------------------
09r_object_id | count(authors)
10------------------------------------------------------------
110900000123ac12f6 | 2
12 
13 
14SELECT mydoc1.r_object_id, mydoc1.authors
15FROM dm_document mydoc1 where
16r_object_id = '0900000123ac12f6'
17and mydoc1.r_object_id IN(select r_object_id from dm_document mydoc2 where any mydoc2.authors IN('James Does'))
18ENABLE (ROW_BASED);
19...
20------------------------------------------------------------
21r_object_id | authors
22------------------------------------------------------------
230900000123ac12f6 | James Does
240900000123ac12f6 | Jules Doe
25 
26 
27SELECT mydoc1.r_object_id, mydoc1.authors
28FROM dm_document mydoc1 where
29r_object_id = '0900000123ac12f6'
30and mydoc1.r_object_id IN(select r_object_id from dm_document mydoc2 where any mydoc2.authors IN('James Does'))
31;
32...
33------------------------------------------------------------
34r_object_id | authors
35------------------------------------------------------------
360900000123ac12f6 | James Does, Jules Doe

 
 

Kind regards,

Huseyin OZVEREN

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

Related Post