PixxelKick
PixxelKick
CC#
Created by ffmpeg -i me -f null - on 6/21/2024 in #help
✅ object composition: a database perspective
Gotta use the query planner to assess where the issue is, usually it's cuz of a missing index
16 replies
CC#
Created by ffmpeg -i me -f null - on 6/21/2024 in #help
✅ object composition: a database perspective
I've done more than 20 joins on 100s of millions of records with filtering and it would run in sub 1s
16 replies
CC#
Created by ffmpeg -i me -f null - on 6/21/2024 in #help
✅ object composition: a database perspective
That's usually just indicative that your indexes aren't setup right
16 replies
CC#
Created by ffmpeg -i me -f null - on 6/21/2024 in #help
✅ object composition: a database perspective
Ive had that many joins before, it's not too bad. Joins on cluster indexes are extremely performant
16 replies
CC#
Created by ffmpeg -i me -f null - on 6/21/2024 in #help
✅ object composition: a database perspective
in such a case, normal navigation properties with EF Core will very likely be plenty to get the job done
16 replies
CC#
Created by ffmpeg -i me -f null - on 6/21/2024 in #help
✅ object composition: a database perspective
It's pretty rare to truly need a genuinely infinitely recursive tree structure. Most applications from clients won't be mad if you impose a reasonable max depth restriction as a tradeoff for it being waaaaay easier to implement
16 replies
CC#
Created by ffmpeg -i me -f null - on 6/21/2024 in #help
✅ object composition: a database perspective
If it's a tree like structure but it has a known maximum tree depth (IE you'll never go more than 3 layers deep), then I'd not actually make it recursive and instead just do normal joins
16 replies
CC#
Created by ffmpeg -i me -f null - on 6/21/2024 in #help
✅ object composition: a database perspective
I typically try to avoid a recursive db schema unless absolutely 100% necessary, when the "depth" of the tree truly has no upper maximum
16 replies
CC#
Created by ffmpeg -i me -f null - on 6/21/2024 in #help
✅ object composition: a database perspective
And tree hierarchies 100% go in the recursion challenge bin, so I'd use a stored proc there
16 replies
CC#
Created by ffmpeg -i me -f null - on 6/21/2024 in #help
✅ object composition: a database perspective
I have a rule for when to use database solutions, soecufucally, Views and Stored procs. When I need to force a sub query for entity framework, I use a ViewTable (so I can keep using EF core on the "outer query") Whenever recursion is involved, I use a Stored Proc. There's no easy way to do recursion any other way for a db query, tbh
16 replies
CC#
Created by PIE on 6/21/2024 in #help
Optimization problem for matching two lists of objects with same property
Anytime you have a db query inside a loop, you can usually pull it out of the loop and use a .Contains to get em all in a single shot
10 replies
CC#
Created by PIE on 6/21/2024 in #help
Optimization problem for matching two lists of objects with same property
That'll do it in effectively 2 update queries, one to set the offline group, one to set the online group
10 replies
CC#
Created by PIE on 6/21/2024 in #help
Optimization problem for matching two lists of objects with same property
var onlineGroups = users.GroupBy(u => u.Online);

foreach (var onlineGroup in onlineGroups)
{
var ids = onlineGroup.Select(u => u.UserId).ToList();
_ = await db.Traders
.Where(t => ids.Contains(t.TraderId)
.ExecuteUpdateAsync(e => e.SetPropety(t => t.Online, onlineGroup.Key);
}
var onlineGroups = users.GroupBy(u => u.Online);

foreach (var onlineGroup in onlineGroups)
{
var ids = onlineGroup.Select(u => u.UserId).ToList();
_ = await db.Traders
.Where(t => ids.Contains(t.TraderId)
.ExecuteUpdateAsync(e => e.SetPropety(t => t.Online, onlineGroup.Key);
}
I think I got that right, trying to do it off by heart
10 replies
CC#
Created by PIE on 6/21/2024 in #help
Optimization problem for matching two lists of objects with same property
Ohhh gptcha
10 replies
CC#
Created by PIE on 6/21/2024 in #help
Optimization problem for matching two lists of objects with same property
Unless it isn't 1:1, in which case you should have a navigation property on user to trader
10 replies
CC#
Created by PIE on 6/21/2024 in #help
Optimization problem for matching two lists of objects with same property
It looks like you have a 1:1 relationship between trader and user which is a DB smell, you shouldn't have 1:1 relationships in a database (1:1 relationship means they should just be the same table)
10 replies
CC#
Created by UnrealSPh on 6/20/2024 in #help
Do we really need microservices in order to scale out an application horizontally?
Are you talking about just having all your microservice projects in the same solution so you can run em all together locally for testing?
18 replies
CC#
Created by eid on 6/20/2024 in #help
✅ what is the name of the pattern that used in types that end with *source?
Factory
27 replies
CC#
Created by uffen on 6/20/2024 in #help
learning moq framework
No description
13 replies
CC#
Created by uffen on 6/20/2024 in #help
learning moq framework
@uffen My recomendation is not used a mock library at all. Avoid mocking stuff entirely except for "on the edge" stuff. Most of which have built in easy ways to mock their data, IE HttpClient has a built in way to mock its response very easily, no library needed. Write code that doesn't need mocking. Once you get into that habit you'll find your tests become substantially easier to write too
13 replies