Click here to Skip to main content
15,885,546 members
Home / Discussions / C#
   

C#

 
AnswerRe: Igroupping with Parallel Pin
Luc Pattyn1-Mar-20 9:04
sitebuilderLuc Pattyn1-Mar-20 9:04 
GeneralRe: Igroupping with Parallel Pin
Member 110035101-Mar-20 18:36
Member 110035101-Mar-20 18:36 
GeneralRe: Igroupping with Parallel Pin
Pete O'Hanlon1-Mar-20 21:21
mvePete O'Hanlon1-Mar-20 21:21 
GeneralRe: Igroupping with Parallel Pin
Member 110035101-Mar-20 22:17
Member 110035101-Mar-20 22:17 
GeneralRe: Igroupping with Parallel Pin
Pete O'Hanlon1-Mar-20 22:42
mvePete O'Hanlon1-Mar-20 22:42 
GeneralRe: Igroupping with Parallel Pin
Richard Deeming1-Mar-20 23:57
mveRichard Deeming1-Mar-20 23:57 
Generaladd DISTINCT drop PARALLEL Pin
Luc Pattyn2-Mar-20 0:48
sitebuilderLuc Pattyn2-Mar-20 0:48 
Generaldrop TOLIST, avoid memory stress Pin
Luc Pattyn2-Mar-20 9:13
sitebuilderLuc Pattyn2-Mar-20 9:13 
Hi,

One more comment:

I'm not very familiar with LINQ and so I'm not sure I understand your code
lstFilters = (from tb in dbLinq.Table
                   group tb by new
                       {
                        tb.Date.Year
                       } into dates
                   select dates.Key.Year).ToList();

very well. It is my guess this is generting a "streamed Dictionary" where the Key is a year, and the Value is an enumerable holding all the table entries matching that year.

If so, calling ToList() on it will cause all this data to be stored in RAM, which implies
(a) the entire DB operation is performed "at once", not in chuncks (sabotaging any attempt for parallel
database accesses);
(b) all this data may amount to gigabytes, possibly causing memory stress and even copying stuff to disk; something the problem at hand does not really require.


You could try omitting ToList() but then AsParallel() might, I don't know, itself cause all data to be retrieved before anything happens. So if you want to keep as close as possible to that original code, I'd suggest you drop both ToList() and AsParallel().


However I still prefer my original suggestion, where an explicit database access is used to get distinctYears; and then a foreach that contains a LINQ or other piece of code to handle only the records pertaining to a particular year. This MSDN page[^] provides a normal example for the foreach content.
And I still would only consider parallelism if and when a good single-thread approach proves too slow.

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum


modified 2-Mar-20 15:31pm.

AnswerRe: Igroupping with Parallel Pin
Eddy Vluggen1-Mar-20 13:47
professionalEddy Vluggen1-Mar-20 13:47 
GeneralRe: Igroupping with Parallel Pin
Member 110035101-Mar-20 22:18
Member 110035101-Mar-20 22:18 
QuestionError must declare scalar variable @ISBN update statement c# Pin
Member 1164145429-Feb-20 5:20
Member 1164145429-Feb-20 5:20 
AnswerRe: Error must declare scalar variable @ISBN update statement c# Pin
OriginalGriff29-Feb-20 5:38
mveOriginalGriff29-Feb-20 5:38 
GeneralRe: Error must declare scalar variable @ISBN update statement c# Pin
Member 1164145429-Feb-20 22:20
Member 1164145429-Feb-20 22:20 
GeneralRe: Error must declare scalar variable @ISBN update statement c# Pin
OriginalGriff29-Feb-20 22:42
mveOriginalGriff29-Feb-20 22:42 
GeneralRe: Error must declare scalar variable @ISBN update statement c# Pin
phil.o29-Feb-20 22:44
professionalphil.o29-Feb-20 22:44 
QuestionESENTUTL in C# Pin
colins528629-Feb-20 4:28
colins528629-Feb-20 4:28 
AnswerRe: ESENTUTL in C# Pin
OriginalGriff29-Feb-20 5:40
mveOriginalGriff29-Feb-20 5:40 
AnswerRe: ESENTUTL in C# Pin
Luc Pattyn29-Feb-20 9:27
sitebuilderLuc Pattyn29-Feb-20 9:27 
AnswerRe: ESENTUTL in C# Pin
Dave Kreskowiak29-Feb-20 10:38
mveDave Kreskowiak29-Feb-20 10:38 
AnswerRe: ESENTUTL in C# Pin
colins52861-Mar-20 22:50
colins52861-Mar-20 22:50 
GeneralRe: ESENTUTL in C# Pin
Richard Deeming1-Mar-20 23:49
mveRichard Deeming1-Mar-20 23:49 
GeneralRe: ESENTUTL in C# Pin
colins52862-Mar-20 6:48
colins52862-Mar-20 6:48 
GeneralRe: ESENTUTL in C# Pin
Richard Deeming2-Mar-20 7:08
mveRichard Deeming2-Mar-20 7:08 
AnswerRe: ESENTUTL in C# Pin
Mc_Topaz3-Mar-20 21:48
Mc_Topaz3-Mar-20 21:48 
QuestionNeed to Change DatagridView POP background color from Vincenzo Rossi Pin
Member 1464144527-Feb-20 17:25
Member 1464144527-Feb-20 17:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.