MJ_01 wrote:
My boss wants to move away from using llblgen because our code causes the database to receive a large amount of calls. I tried explaining to him that this is because llblgen works by avoiding duplicate data. He would rather use a stored proc that gets all the data in a single call even if most of it is duplicated. Also stored procs can be optimized over time through a query execution plan
You won't get less calls when moving to procs, if you want less calls you should write queries which pull more data at once, everything a proc can do is also possible in an llblgen pro query so I don't see why a proc would help here. A proc isn't an equivalent either: it's just a query. How are you going to handle the resultset? Or sets? How are you going to deal with changes?
Please see below for what I think is your problem though, so it's fixable
Execution plans are created from dynamic sql as well and optimized/reused. There's no difference with a proc, so that's a myth.
Are there any other benefits of using LLBLGen? Any good arguments I can make?
Instead of my Collection.GetMulti() call making 50 calls to the db, is it possible to change a setting to have it make one call even if most of the data is duplicate?
GetMulti makes 1 call to the database (or if you specify a prefetch path it will perform 1 query per node, but a prefetch path of 50 nodes is rare, so I guess it's not that), so if you see 50 calls, you have a SELECT N+1 problem, which is caused by lazy loading, I think. If you're on 5.3 or higher, you can switch off lazy loading completely: https://www.llblgen.com/Documentation/5.4/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/SelfServicing/gencode_usingentityclasses_lazyloading.htm#how-to-switch-off-lazy-loading-completely
If not, you should look into defining a prefetch path which fetches the data eagerly instead of with lazy loading. The queries are coming from calls reading the properties of the fetched entities using the GetMulti() call. So you should be able to fix this yourself and gain a lot of performance. SELECT N+1 is a problem that has a solution, without needing to use procs.
So let's investigate this problem further so you can solve it on your end and remove the only argument your boss has: the large amount of queries
(btw, if this app is on .net full, you can use ORM Profiler for finding which queries are SELECT N+1 queries https://www.ormprofiler.com. You can try a trial first if you just want to find them quickly. Not to push you into using yet another product, your boss likely won't buy it but it would give you an initial insight in what's going on.)