Code vs. Sproc

Discussion in 'Databases' started by fraser, Jan 5, 2011.

  1. In developing my application, I have the option to move some of my business logic into Database Stored Procedures vs. ASP.NET code (C#). From a performance/utilization perspective is there a preference? I have a Max Plan if that makes a difference? Thank you for any feedback or insight into this.
    fraser.
     
  2. Ray

    Ray

    I'm not quite sure I understand what you are asking. What do you mean by

    Database Stored Procedures vs. ASP.NET code (C#)
     
  3. Whether the performance will be better using SQL or web site code is difficult to answer because every application and database is different. Generally speaking, most people I know prefer to write logic into the application or site code rather than a SQL query or procedure. The idea being that the database should be a data store only, and the manipulation of the data should occur in the application.

    But the decision is almost as philosophical as it is technical. Performance-wise, in a shared hosting environment, I would lean toward less reliance on the database to perform logic. Just because resources are generally more available on the web server side. But again, a lot of that depends on the application. There isn't really a cut and dried answer, but it's an interesting question.
     
  4. My plan is a shared Hosting plan, with an unknown Processor/Memory configuration. If my business logic takes 1 second per page to generate am I better off putting some of that workload on the database server vs. the Web server.

    Maybe think of it like this.
    If DB server and Web server are on identical hardware and the web server is shared by 10 users while the database server is shared by 20 users I would design so that 2/3 of my code was on the web server and 1/3 on the database server. In my day job I have to think about all of these tiers so maybe I'm just over thinking it.

    Thanks.
     
  5. Ray

    Ray

    Our web servers and SQL servers are on two different hardwares so in that sense of optimization it will give you a benefit, but its still hard to say because we are not the ones to design your application and database. First off, I will need to warn you that our SQL servers do not have the CLR enabled. Not that you cannot run stored procedures but if your stored procedure actually has C# code that needs to be compiled and processed by the SQL server then I'm afraid we cannot do this and you will need to run it on our web server. This is because of strict resources and security policies we have to place on the SQL server to protect the other databases we host.

    But to really get a good understanding of how your application will perform I can only suggest to set it up on your testing environment and see how it runs.
     

Share This Page