Multiple queries generated for GetDbCount

Posts   
 
    
Posts: 17
Joined: 23-Feb-2007
# Posted on: 01-Dec-2008 19:34:43   

This code...

KMI.Orm.CollectionClasses.VersionCollection versions = new KMI.Orm.CollectionClasses.VersionCollection();
versions.GetDbCount(new PredicateExpression(), new RelationCollection());

generates two very similar queries...

SELECT [dbo].[version].[VersionID] AS [VersionId], [dbo].[version].[Major], [dbo].[version].[Minor], [dbo].[version].[Revision], [dbo].[version].[VersionDate], [dbo].[version].[User], [dbo].[version].[Notes] FROM [dbo].[version] 
SELECT COUNT(*) AS NumberOfRows FROM (SELECT [dbo].[version].[VersionID] AS [VersionId], [dbo].[version].[Major], [dbo].[version].[Minor], [dbo].[version].[Revision], [dbo].[version].[VersionDate], [dbo].[version].[User], [dbo].[version].[Notes] FROM [dbo].[version] ) TmpResult

Is there a way to avoid basically the same query being executed twice? In the case of non-trivial queries it hurts performance. I've tried using GetDbCount and GetScalar of DAO classes but always see two queries generated.

(This is with SQL Server 2005, version 2.6 of LLBLGen.)

Posts: 17
Joined: 23-Feb-2007
# Posted on: 01-Dec-2008 19:53:17   

Hold on. I think I found my answer in another post. http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=12524&HighLight=1. I'm not sure why that post isn't found when I type its exact title in the search.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 01-Dec-2008 20:37:49   

It indeed should reveal that thread... (subjects of threads together with message texts are searched). I'll see if I can find out why the search query doesn't reveal any results.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 02-Dec-2008 12:30:54   

When I run a CONTAINS(Subject, 'TypedView AND Where' query directly on the database, it returns 0 rows, while there is a thread with that as subject. Strange. Might be a sqlserver 2008 thing, I'll see if I can repro it on 2005 and 2000 as well.

(edit)ah... when a stopword is in the query, it's not resulting in any rows. In sqlserver 2008, stopwords are inside the DB. They're filtered out in the query, but as the lists don't match anymore, some are missed. Like the subject for this thread. When you include 'for', it's not resulting in any rows. not including 'for' will result in a row, this thread.

(edit) hmm... profiling suggests, it's not filtering on subject. Looking into this.

(edit) OH! smile flushed

It's a feature simple_smile In the search page, you can select what to search: Message text, Thread subject or both. By default, message text is selected, as opting for both makes the search slower. So picking just 'message text' in the seach page will not result in the proper results if there's no message matching the search terms but a thread subject did.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 17
Joined: 23-Feb-2007
# Posted on: 02-Dec-2008 16:01:19   

Thanks for looking into it. Sorry for planting the seed of confusion.