Here is a very good video on the subject, by Dr. Robin Glover, the author of SharpCap -- "Choosing the right gain for Deep Sky imaging with CMOS cameras":

https://www.youtube....h?v=ub1HjvlCJ5Y

BTW, the above video is an "addendum" to a more general/broad video on the topic of CMOS imaging, "Deep Sky CMOS Astrophotograhy | PAS 2019", which provides excellent outlook of how the use of CMOS (vs. CCD) sensors changes overall approach to DS imaging:

https://www.youtube....h?v=3RH93UvP358

I should add that second video, while very interesting in itself, is also essential for full understanding the first one.

For instance, the first video starts with a formula with hard-coded coefficient of 10 in the equation for the optimal sub exposure length (10*R^2/P). Why "10"? That's a coefficient that Dr. Glover calls "C Factor", which corresponds to the noise tolerance of 5%, as shown in the second video, here: https://www.youtube....93UvP358&t=2940 (C factor is 25 for 2% of allowed noise, etc.; that video has a formula for it).

Additionally, there are some very useful resources at SharpCap site that greatly facilitate calculations of the amount of shot noise due to light pollution -- which propagates throughout all calculations (in a nut shell, the recommendation is use the lowest gain that fits your minimum sub exposure length requirement... plus some "nuances", of course, like step reduction etc.), so you should probably handle them first, and then get on with the optimal gain estimate. While videos contain data (tables and charts) for some LP/scope/camera combinations, you can precisely calculate coefficients for your own setup (LP/scope/camera/filter[s]) using the following:

http://tools.sharpcap.co.uk