I have a Asp.net project with complex calculation in database. for example: i need to Calculate staff salaries. this query action for Calculate staff salaries is very long and complex, because should calculated staff working hours Also, vacation and missions in per month. my question : do i use function sql server or entity framework query for this calculation? Which is better performance?
I have a Asp.net project with complex calculation in database. for example: i need
Share
Impossible to answer.
In general:
SQL is great in calculating standard elements without business logic. Group by date, statistic distribution etc.
If you get into legal issues with a lot of decisions, it may be better for maintenance etc. to do things in the application. Also becqause SQL is harder to debug AND because these may change. If you grow you may have to have different logic for differen type of people – lot of decisions, easire to do when differen people groups run different scripsts coded in diferent classes.
I think this is better done with more logic inclined programming – i.e. outside of SQL. It is also not a LOT of data to process there unless you are a large company.
Who cares about that?
SQL will be better, but the question is whether it matters. If it takes 5 minutes for you once per month and 1 minute in sql server then sql server is better but it is irrelevant. Perforamnce driven architectures are important – when it makes a difference. In this cae I doubt it does. You can likely calculate way more than 1 employee per second outside sql server per thread. Modern desktop higher end = 12 threads = 12 people per second = 720 people per minute. You can easily take a night (8 hours) once per month for the calculation. Do the math yourself. Performance is basically a non-issue here.
Stuff like that is done batched anyway – you an do nightly batches or monthly batches and then you have all the time (run it first of the month, finished). This is premature optimization because it only is an issue with 10.000+ people on staff.
I would go more towards mainteance long term while the legal and contractual side changes over time.