COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: cognos_guru on 07 Jul 2009 02:17:48 PM

Title: Query Subject Shortcuts - Does the query run twice against the DB?
Post by: cognos_guru on 07 Jul 2009 02:17:48 PM
I have a query subject which returns X number of rows that I want to be displayed in a list.  Underneath that, I want another list to filter those X number of rows to exclude rows that have a certain attribute. 

I know that I cannot point both lists to the same query subject because my filter would result in filtering both lists... What are the alternatives here?  If possible, I'd like to only hit the Database with one query.

If I create a shortbut to the query subject in framework manager with the filter, will the report generate only one query against the database, or will it still be two?

Thanks
Title: Re: Query Subject Shortcuts - Does the query run twice against the DB?
Post by: DustPanMan on 09 Jul 2009 09:39:46 AM
You can create the one query that is hitting the database and have it used for the top list and then create a subquery (In Query Explorer, drag a query to the left of it).  Then pull in all of the Data Items you want and filter at the new query level.
Title: Re: Query Subject Shortcuts - Does the query run twice against the DB?
Post by: cognos_guru on 13 Jul 2009 10:42:51 AM
Would using a sub-query cause the application to run two queries against the database or just one?  I would need two result sets displayed seperately- one using the full query and one with the filtered data.
Title: Re: Query Subject Shortcuts - Does the query run twice against the DB?
Post by: DustPanMan on 14 Jul 2009 10:46:30 AM
Just one query against the database.  2 for display.  It should do precisely what you are looking for.
Title: Re: Query Subject Shortcuts - Does the query run twice against the DB?
Post by: cognos_guru on 15 Jul 2009 10:40:47 AM
Just an FYI -

I added a sub-query subject to filter off the results of the first query subject.  The results are accurate; however when I check the activity against the database, there are still two hits.  The first is the full query, the second uses a WITH to filter on the results of the first query
Title: Re: Query Subject Shortcuts - Does the query run twice against the DB?
Post by: DustPanMan on 22 Jul 2009 01:41:15 PM
Yikes.  Try setting the first Query to use caching and the second for "Limited Local" processing.