DFQuery Constants

The JavaDocs for the DFC indicate that the IDfQuery.execute() method requires two parameters:  session and queryType. OK, the session is easy, but have you ever stopped to consider what the queryType parameter does?  Most of us probably just hardcode a ‘1’ for this parameter and continue coding.  However, the parameter does have meaning and use, and depending upon your application and your query, an effect on results and performance.  For convenience, the queryType values have been encapsulated as constants in the DfQuery class and can be used by name, e.g., DFQuery.DF_QUERY.  The following table contains all of the queryType constants defined in the DfQuery class and their effects on queries.

Constant Value Effect
DF_READ_QUERY 0 Use this query type for queries containing SELECT statements that will not make changes to the repository. You can execute non-SELECT statements with a DF_READ_QUERY query, but there are no performance benefits in doing so. Note that if a DF_READ_QUERY query makes changes to the repository during processing, the collection returned by the query closes automatically. When the collection is closed, up to batch_hint_size objects will be modified but no error or exception will be raised. Consequently, if you want a query to make changes to a repository during processing, use a DF_QUERY query
DF_QUERY 1 This is a general-purpose query type and the one most commonly used, notice that it corresponds to the ‘1’ mentioned in the text above.  Use this query type for any DQL statement. However, you must use this query type for queries that make changes to the repository.
DF_CACHE_QUERY 2 This query type indicates that a query executes as read-only and stores the results in a query cache file. Cached queries can improve performance for queries whose results are generally static. For example, you might use a DF_CACHE_QUERY query to return the names of users in the repository. To implement cached queries, you need to configure the DFC to store the query results in the client query cache. See the EMC Documentum Content Server Fundamentals guide.
DF_EXEC_QUERY 3 This query type is the same as the DF_QUERY query type but should be used when the query string is longer than 256 characters. At least that’s what the documentation says. EDN users report that query strings longer than 256 characters run fine with DF_QUERY and that this limitation may have only existed in “old” versions of Documentum.
DF_EXECREAD_QUERY 4 This query type is the same as the DF_READ_QUERY query type but should be used when the query string is longer than 256 characters. At least that’s what the documentation says. EDN users report that query strings longer than 256 characters run fine with DF_READ_QUERY and that this limitation may have only existed in “old” versions of Documentum.
DF_APPLY 5 Use this query type for queries that invoke procedures that perform system administration functions or run external procedures. For example, GET_PATH or GET_INBOX.

It is good form and best practice to use the DfQuery constants in your DFC code instead of just hardcoding a ‘1’ for the queryType.  First, it makes your code easier to read and insulates you from any changes EMC might make to the implementation of the queryType.  Second, it might actually buy you some performance.

Advertisements

About Scott
I have been implementing Documentum solutions since 1997. In 2005, I published a book about developing Documentum solutions for the Documentum Desktop Client (ISBN 0595339689). In 2010, I began this blog as a record of interesting and (hopefully) helpful bits of information related to Documentum, and as a creative outlet.

3 Responses to DFQuery Constants

  1. Pingback: DFC Constants Can Be Insightful « dm_misc: Miscellaneous Documentum Tidbits and Information

  2. Pingback: The Basics – Running a Query | dm_misc: Miscellaneous Documentum Information

  3. Pingback: The Basics – Specialized Query Methods | dm_misc: Miscellaneous Documentum Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: