Background:
We are building an batch processing application which will be responsible for iterating through several hundred thousand to a couple of million insurance claims. Performance is of the highest priority, since even one extra database call per claim could mean half a million extra database calls over the whole run.
Currently, we grab a couple thousand claims into memory at a time and process those. Each of these claims has several related entities which we need to examine.
The Problem
When I create a prefetch path to get all the related entities, LLBLGen produces subqueries which return the entire table. I understand that LLBLGen creates the subqueries differently if the number of entities is low enough (50, I believe). Since I am dealing with several thousand claims at a time, the select statement gets the whole table instead of the rows that are based upon the primary key of the parent table. This is unacceptable since those related tables could contain millions of records, and that would kill memory, etc.
Am I doing something wrong? Here is what my prefetch paths look like:
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.CmcClclClaimEntity);
prefetchPath.Add(CmcClclClaimEntity.PrefetchPathCmcGrgrGroup).SubPath.Add(CmcGrgrGroupEntity.PrefetchPathCmcGrreRelation);
prefetchPath.Add(CmcClclClaimEntity.PrefetchPathCmcCddlClLine).SubPath.Add(CmcCddlClLineEntity.PrefetchPathCmcCddcDnliCob);
prefetchPath.Add(CmcClclClaimEntity.PrefetchPathCmcCdmlClLine).SubPath.Add(CmcCdmlClLineEntity.PrefetchPathCmcCdcbLiCob);
prefetchPath.Add(CmcClclClaimEntity.PrefetchPathCmcClstStatus);
and here is what the resulting sql calls look like:
SELECT TOP 200 <SNIP> FROM [dbo].[CMC_CLCL_CLAIM]
SELECT <SNIP> FROM [dbo].[CMC_GRGR_GROUP]
WHERE ( [dbo].[CMC_GRGR_GROUP].[GRGR_CK] IN (
SELECT [dbo].[CMC_CLCL_CLAIM].[GRGR_CK] AS [GrgrCk] FROM [dbo].[CMC_CLCL_CLAIM]))
The rest of the related queries...
The second table could contain millions of rows, so I obviously don't want to bring that whole thing back every time I get the next batch of queries. Is there anything I can do here? I'm using 1.0.2005.1, Adapter Scenario.
Thanks,
Matt Hornsby