I started using this type of a query construct where Query 2 is a subset of the more complicated Query 1. This allows me to reference an existing query and filter out only certain items of Query 1. I have a couple questions about this type of query construct.
- What do you call type of query construct identified by Query 2
- Is this a best practice?
(https://lh3.googleusercontent.com/-UFMEUGS7_Vg/WYHm7Xj4kcI/AAAAAAAADaI/eKZLltpv9h4K8CHX0XtNJ-X6Ypi1BfoqwCJoC/w530-h535-p-rw/Query%2BItems.PNG)
Quote from: Cape Cod Gunny on 02 Aug 2017 10:03:06 AM
I started using this type of a query construct where Query 2 is a subset of the more complicated Query 1. This allows me to reference an existing query and filter out only certain items of Query 1. I have a couple questions about this type of query construct.
- What do you call type of query construct identified by Query 2
- Is this best practice?
(https://lh3.googleusercontent.com/-UFMEUGS7_Vg/WYHm7Xj4kcI/AAAAAAAADaI/eKZLltpv9h4K8CHX0XtNJ-X6Ypi1BfoqwCJoC/w530-h535-p-rw/Query%2BItems.PNG)
I would call it a query reference.
It is a good technique to keep the overall code base small and to keep the important logic in one place. I would try to have Query1 return the smallest possible result set for subsequent filtering. For example, filter Query1 as much as possible to focus on what you need to satisfy other queries and keep the granularity of the results as high as you can (e.g., automatically grouped and summarized to the highest level possible).
I've seen questions posted in the past about what actually happens in the database versus locally on the Cognos server but I don't recall a definitive answer. The best I can suggest is to be aware of performance implications in case they affect you. Maybe someone who knows more about the inner workings will chime in on this also.
@Lynn, thank you. I didn't know what it was called and it helps a lot knowing it is a "Reference Query".
I found this post that explains the use and re-use of queries. http://www.cognoise.com/index.php?topic=12032.0 (http://www.cognoise.com/index.php?topic=12032.0)
I'm good to go!