public void CreateMainIndexes(bool afterPost, Stopwatch sw) { if (afterPost) { FNameData.PrepareForSort(); SNameData.PrepareForSort(); SexData.PrepareForSort(); StatusData.PrepareForSort(); CityData.PrepareForSort(); CountryData.PrepareForSort(); CodeData.PrepareForSort(); DomainData.PrepareForSort(); BirthYearData.PrepareForSort(); InterestsData.PrepareForSort(); JoinedYearData.PrepareForSort(); PremiumData.PrepareForSort(); GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; GC.Collect(); GC.WaitForFullGCApproach(); Console.WriteLine($"Preparation for sort done in [{sw.ElapsedMilliseconds}] ms"); Task.Run(() => { LikesBuffer.FillLikes(); LikesBuffer = null; Console.WriteLine($"Likes filling done in [{sw.ElapsedMilliseconds}] ms"); }); } var preparationForGroup1 = Task.Run(() => { EmailsStorage.SortAndPropagate(); FNameData.Sort(); SNameData.Sort(); SexData.Sort(); }); var preparationForGroup2 = Task.Run(() => { StatusData.Sort(); CityData.Sort(); CountryData.Sort(); CodeData.Sort(); DomainData.Sort(); }); var preparationForGroup3 = Task.Run(() => { BirthYearData.Sort(); InterestsData.Sort(); JoinedYearData.Sort(); PremiumData.Sort(); }); Task.WaitAll(preparationForGroup1, preparationForGroup2, preparationForGroup3); Console.WriteLine($"Ids sorting done in [{sw.ElapsedMilliseconds}] ms"); Holder.Instance.Group.CleanCacheAndCreateNewCache(); Console.WriteLine($"Cache recreating done in [{sw.ElapsedMilliseconds}] ms"); Statistics(false); }