Hi. I have two long queries, each of type "typeViewRequest"
results1 = ..... (timeout)
results2=..... (timeout)

Case
1-----------------------------------------------------------------------------
If I do
results1 = ..... .Take(countRecordsToShow/2)
results2 = ..... .Take(countRecordsToShow/2)

and then I say
results = results1.Union<typeViewRequest>(results2);

it works fine. The grid, using paging, shows the countRecordsToShow
records, no problem here.

Case
2-----------------------------------------------------------------------------
If I do
results1 = .....
results2 = .....

and then I say
results =
results1.Union<typeViewRequest>(results2).Take(countRecordsToShow)

then I have a timeout. I assume that UNION actually executes BEFORE
the TAKE has a chance to limit the dataset. It means I have to use
Case1.

BUT !!!!

I also have some filtering to do. This filtering should happen on BOTH
branches, like so:

results1 = .....  Where (something1)
results2 = ..... .Where (something2)

but if I say

results1 = .....  Where (something1).Take(countRecordsToShow/2)
results2 = ..... .Where (something2).Take(countRecordsToShow/2)

this will CUT my filtered datasets, I'm afraid - let's say that
countRecordsToShow = 20. If results1 (filtered by something1) had,
say, 15 records, I will take only 10. If results2 (filtered by
something2) had, say, 5 records, I will take 5. Then the UNION would
have 15 instead of 20 records.

Normally I should do this:

results1 = .....  Where (something1)
results2 = ..... .Where (something2)

AND then say
results =
results1.Union<typeViewRequest>(results2).Take(countRecordsToShow)

If results1.Union<typeViewRequest>(results2) had 25 records but
countRecordsToShow were 20, then so be it. I would say that the
dataset is not complete, and additional filtering is necessary.

But since I have to trim the dataset BEFORE the UNION, this will
affect my filtering BADLY !

I expected that the resulted query will first pull each branch, then
execute the UNION, then filter, and then trim, right at the end.

Well, apparently if I don't trim each branch, I get a timeout.

I can't even say "If filter criteria != null, then don't trim, show
all", since if I don't trim, the UNION might already time out.

How does this all work ? I'm VERY confused. I cannot even use a COUNT
to find out how many records I should expect, and to behave in
consequence, because COUNT enumerates the dataset, thus giving me a
timeout.

Reply via email to