Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 where should be the calculations be made?

Author  Topic 

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-28 : 22:46:51
where should be the calculations be made based on performance, in SQL or in front end?

thanks.
-Ron-

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-03-28 : 23:10:15
It depends.


CODO ERGO SUM
Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-28 : 23:14:04
quote:
It depends.

depends on what? Can you site a situation?

thanks.
-Ron-
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-03-28 : 23:25:22
It depends on the requirements and architecture of the application.

Do you have a specific problem that you are trying to solve, or is this just a philosophical, interview, or homework question?




CODO ERGO SUM
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-03-28 : 23:28:39
do what's most efficient.

clients should fetch only the data they need, and they should fetch it in the fewest possible calls to the server. if you need 100 rows, ask for the 100 rows you need. Don't fetch 100k rows and then filter them on the client.

also fetch only the columns you need, not all that are available. Finally, fetch your rows in only one server call, not 100 separate calls.

it seems obvious, but there it is.




www.elsasoft.org
Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-28 : 23:44:03
quote:
It depends on the requirements and architecture of the application.

Do you have a specific problem that you are trying to solve, or is this just a philosophical, interview, or homework question?

I am doing HR Payroll system and reports on payroll with lots of computation. Somebody told me that it is better to perform calculation in SQL and others in front-end. which is which? dont know what to follow....

thanks.
-Ron-

Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-28 : 23:45:37
quote:
do what's most efficient.

OK thanks.

-Ron-
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2007-03-29 : 23:06:45
Another thing to consider when you get more 'enterprisey' is that some things are business rules and some are application rules and a decent (i.e. useful) database will often have multiple applications hanging off it.

For example, applying a pay rise should be a 'business rule'. There are no exceptions throughout the business as to how this should be done. This should be done in the database to avoid multiple applications attempting to do the same thing in different ways.

Conversely, someone might want to see a particular slice of data for a particular application (e.g. employees who are consistently absent on certain days). This is probably more of a per-application view and each department may have different ways of dealing with this, accessed by its own application.

I'm not too sure the second example is a great one, but hopefully you get the idea. Certain things fall into clear categories when you think along those lines.
Doesn't quite answer your question I suppose, but might give you a new perspective.
Go to Top of Page
   

- Advertisement -