Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. No more stored procedures

No more stored procedures

Scheduled Pinned Locked Moved The Lounge
databasecsharpsql-servercomsysadmin
152 Posts 63 Posters 14 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Joe Woodbury

    After I posted that I realized I should have written "stored procedures CAN improve performance" since I actually know of cases where they cause lower performance (which I eluded to in a later sentence.) (I modified my original post with a note indicated that I had done so.)

    Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke

    M Offline
    M Offline
    Member 96
    wrote on last edited by
    #14

    I guess anything is possible, I've never seen it be the case in practice, my apps are business apps and make *extreme* use of the power of the database engine itself and I've tested and timed and profiled with all manner of different queries and back end databases when I was researching going to a data access layer a couple of years ago and I could never find a perceptible difference between dynamic and stored procedure. Something which a lot of people said would be the case despite the common belief that stored procedures are always faster. I'm kinda intense on this issue :) and any other issue involving software development where people have beliefs that aren't validateable in the real world. I think I'm going to publish a "Heretics guide to software development" explaining why Frames are not necessarily a bad thing in web applications, why stored procedures are a bad thing in commercial application design etc etc. I can only imagine the grief people would try to give me! :)

    P P R M 4 Replies Last reply
    0
    • M Member 96

      James R. Twine wrote:

      Not only does it have the possibility of reducing performance over stored procedures

      Ancient fallacy! If you're talking microseconds, once per query then you're right, if you're talking about something noticeable to the end user, that's complete hogwash.

      James R. Twine wrote:

      you have the chance for something else to insert into the table in-between the two SQL calls you have to insert and then to get back the identity value.

      Yeah, that's just plain wrong, when you go dynamic sql you generate your own unique identifiers in code. (Guid's rock for this)

      J Offline
      J Offline
      James R Twine
      wrote on last edited by
      #15

      John Cardinal wrote:

      Ancient fallacy! If you're talking microseconds, once per query then you're right, if you're talking about something noticeable to the end user, that's complete hogwash.

      That depends entirely on how often the query is being executed, the type of query, etc.  The multiple round-trips also take unnecessary time.  Even microseconds can add up.  I would rather be the application that can show a benchmark of 10231 records/sec instead of a competing application that does 10074 records/sec, or consumes 25% less of the CPU time and requires less memory than the other one.    Performance matters - you are not the only application on a target system competing for system resources, nor the only user of the database.    Peace!

      -=- James


      If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
      Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
      DeleteFXPFiles & CheckFavorites (Please rate this post!)

      M 1 Reply Last reply
      0
      • M Member 96

        Stored procedures should never be used in a commercial software application. 1) Performance is not noticeably better to the end user. That used to be true a very long time ago supposedly, I don't know from personal experience because I wasn't databasing in the 70s and 80's. I can testify without a shadow of a doubt that it is no longer true for FireBird, MS SQL server or Oracle. I had a major app that was targetted exclusively at MS SQL server, about halfway through development we came to our senses and decided to target different databases, I personally have benchmarks and a lot of experience converting the app to DAL and there is no question that the end user will never see a difference in peformance either way. 2) All data access should be done through a data access layer in a properly stratified design, i.e. presentation layer, business object layer, data access layer (and usually more in between). This gurantees portability, forcing your end user into a particular database brand when it's easy to write an independant DAL for different DB's is just stupid. 3) There are many *many* things you can not do with stored procedures that you can easily do in code. 4) There is little or nothing you can do to protect your intellectual property when it's in plain sight in the database in stored procedures. 5) There is no security issue with using dynamic sql as long as you know what you are doing. I agree completely with your boss on the first part, on the second part about inserting a record adn retreiving it's unique id that's completely wrong for dynamic sql, instead generate the ID's at the application and insert the record in one trip. We use Guid's for that exactly to avoid the whole server generated identity trap.

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #16

        John Cardinal wrote:

        Stored procedures should never be used in a commercial software application.

        Wow....

        John Cardinal wrote:

        Performance is not noticeably better to the end user.

        I guess that depends. How can you claim that it never is when 1 - stored procs are precompiled 2- stored procs lower the amount of network traffic required to make a request

        John Cardinal wrote:

        All data access should be done through a data access layer in a properly stratified design

        Correct. And, using stored procs can help do this. How much code do you see on the web where people type SQL right into aspx files, for example ?

        John Cardinal wrote:

        There are many *many* things you can not do with stored procedures that you can easily do in code.

        How is this possible, when a stored proc is just a bunch of SQL ? Name 3.

        John Cardinal wrote:

        There is little or nothing you can do to protect your intellectual property when it's in plain sight in the database in stored procedures.

        If you're writing a C++ app, this is true. Assuming someone has access to your SQL Server, they can see your SQL.

        John Cardinal wrote:

        There is no security issue with using dynamic sql as long as you know what you are doing.

        It's true that dynamic SQL doesn't guarentee security issues, but it does remove the easiest way to add security - the logged in user should only be allowed to call stored procs.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

        J C M 3 Replies Last reply
        0
        • M Member 96

          Stored procedures should never be used in a commercial software application. 1) Performance is not noticeably better to the end user. That used to be true a very long time ago supposedly, I don't know from personal experience because I wasn't databasing in the 70s and 80's. I can testify without a shadow of a doubt that it is no longer true for FireBird, MS SQL server or Oracle. I had a major app that was targetted exclusively at MS SQL server, about halfway through development we came to our senses and decided to target different databases, I personally have benchmarks and a lot of experience converting the app to DAL and there is no question that the end user will never see a difference in peformance either way. 2) All data access should be done through a data access layer in a properly stratified design, i.e. presentation layer, business object layer, data access layer (and usually more in between). This gurantees portability, forcing your end user into a particular database brand when it's easy to write an independant DAL for different DB's is just stupid. 3) There are many *many* things you can not do with stored procedures that you can easily do in code. 4) There is little or nothing you can do to protect your intellectual property when it's in plain sight in the database in stored procedures. 5) There is no security issue with using dynamic sql as long as you know what you are doing. I agree completely with your boss on the first part, on the second part about inserting a record adn retreiving it's unique id that's completely wrong for dynamic sql, instead generate the ID's at the application and insert the record in one trip. We use Guid's for that exactly to avoid the whole server generated identity trap.

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #17

          Hear hear! I've had stored procedures "disappear" from the database (SQL Server); one minute it's there, next minutes it's gone, and the whole system fails.

          C 1 Reply Last reply
          0
          • P PIEBALDconsult

            Hear hear! I've had stored procedures "disappear" from the database (SQL Server); one minute it's there, next minutes it's gone, and the whole system fails.

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #18

            That's never happened to anyone I know, sounds like an issue on your end.

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

            M 1 Reply Last reply
            0
            • C Christian Graus

              John Cardinal wrote:

              Stored procedures should never be used in a commercial software application.

              Wow....

              John Cardinal wrote:

              Performance is not noticeably better to the end user.

              I guess that depends. How can you claim that it never is when 1 - stored procs are precompiled 2- stored procs lower the amount of network traffic required to make a request

              John Cardinal wrote:

              All data access should be done through a data access layer in a properly stratified design

              Correct. And, using stored procs can help do this. How much code do you see on the web where people type SQL right into aspx files, for example ?

              John Cardinal wrote:

              There are many *many* things you can not do with stored procedures that you can easily do in code.

              How is this possible, when a stored proc is just a bunch of SQL ? Name 3.

              John Cardinal wrote:

              There is little or nothing you can do to protect your intellectual property when it's in plain sight in the database in stored procedures.

              If you're writing a C++ app, this is true. Assuming someone has access to your SQL Server, they can see your SQL.

              John Cardinal wrote:

              There is no security issue with using dynamic sql as long as you know what you are doing.

              It's true that dynamic SQL doesn't guarentee security issues, but it does remove the easiest way to add security - the logged in user should only be allowed to call stored procs.

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

              J Offline
              J Offline
              James R Twine
              wrote on last edited by
              #19

              Christian Graus wrote:

              If you're writing a C++ app, this is true. Assuming someone has access to your SQL Server, they can see your SQL.

              I was going to reply to the OP, but... Not really - we have had little utilities like strings for quite some time now.  If you have enough permissions to launch the application, you have enough to dump the binary into an editor and/or get the strings out of it.  Unless you encode the strings in some manner, they are in the binary in plaintext.    Another reason for having the SP - just because a user can execute an SP via an application does not necessarily mean that they have permission to get directly to the database and execute sp_helptext.    Peace!

              -=- James


              If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
              Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
              DeleteFXPFiles & CheckFavorites (Please rate this post!)

              M 1 Reply Last reply
              0
              • J James R Twine

                John Cardinal wrote:

                Ancient fallacy! If you're talking microseconds, once per query then you're right, if you're talking about something noticeable to the end user, that's complete hogwash.

                That depends entirely on how often the query is being executed, the type of query, etc.  The multiple round-trips also take unnecessary time.  Even microseconds can add up.  I would rather be the application that can show a benchmark of 10231 records/sec instead of a competing application that does 10074 records/sec, or consumes 25% less of the CPU time and requires less memory than the other one.    Performance matters - you are not the only application on a target system competing for system resources, nor the only user of the database.    Peace!

                -=- James


                If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                DeleteFXPFiles & CheckFavorites (Please rate this post!)

                M Offline
                M Offline
                Member 96
                wrote on last edited by
                #20

                Of course it depends, everything *depends*, it depends on how the query was written and the knowledge and experience of the developer. Knowledgeable and experienced programmers are always going to wrap queries into the fewest possible trips to the server anyway which has nothing to do with stored procedures or dynamic sql so that's a moot point. The only difference between a stored procedure and dynamic sql is compilation time of the query which is cached anyway in most rdbm's which makes the whole argument moot, but for the sake of it even assuming it isn't cached, how much difference do you think the end user of the application is going to see between one query that uses a precompiled execution plan (which may in fact be recalculated anyway) to one that doesn't? User's care about features and functionality, sacrificing either of those to save that user a total of maybe 10 seconds waiting time over the entire course of a day isn't really very smart now is it?

                J 1 Reply Last reply
                0
                • C Christian Graus

                  That's never happened to anyone I know, sounds like an issue on your end.

                  Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                  M Offline
                  M Offline
                  Member 96
                  wrote on last edited by
                  #21

                  Of course it happens, your scope of experience maybe doesn't encompass it, but try selling commercial software that depends on stored procedures that end users can and will mess about with on their own on a regular basis. Madness!

                  C 1 Reply Last reply
                  0
                  • J James R Twine

                    Christian Graus wrote:

                    If you're writing a C++ app, this is true. Assuming someone has access to your SQL Server, they can see your SQL.

                    I was going to reply to the OP, but... Not really - we have had little utilities like strings for quite some time now.  If you have enough permissions to launch the application, you have enough to dump the binary into an editor and/or get the strings out of it.  Unless you encode the strings in some manner, they are in the binary in plaintext.    Another reason for having the SP - just because a user can execute an SP via an application does not necessarily mean that they have permission to get directly to the database and execute sp_helptext.    Peace!

                    -=- James


                    If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
                    Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
                    DeleteFXPFiles & CheckFavorites (Please rate this post!)

                    M Offline
                    M Offline
                    Member 96
                    wrote on last edited by
                    #22

                    James R. Twine wrote:

                    Not really - we have had little utilities like strings for quite some time now. If you have enough permissions to launch the application, you have enough to dump the binary into an editor and/or get the strings out of it. Unless you encode the strings in some manner, they are in the binary in plaintext.

                    I can't tell you the number of clients over the years that have messed with databases that we include with our software. They see it, have a little experience and want to mess with it. Stored procedures are easily messed with by end users, dynamic sql isn't. The number one security threat for commercial software developers is protecting users from themselves, external threats are a distant second.

                    C C M 3 Replies Last reply
                    0
                    • M Member 96

                      Of course it happens, your scope of experience maybe doesn't encompass it, but try selling commercial software that depends on stored procedures that end users can and will mess about with on their own on a regular basis. Madness!

                      C Offline
                      C Offline
                      Christian Graus
                      wrote on last edited by
                      #23

                      I agree - for the same reason, no application should ever use the registry, or have a config file. I mean, those pesky end users, they can never be trusted, or educated, for that matter.

                      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                      P M 2 Replies Last reply
                      0
                      • C Christian Graus

                        John Cardinal wrote:

                        Stored procedures should never be used in a commercial software application.

                        Wow....

                        John Cardinal wrote:

                        Performance is not noticeably better to the end user.

                        I guess that depends. How can you claim that it never is when 1 - stored procs are precompiled 2- stored procs lower the amount of network traffic required to make a request

                        John Cardinal wrote:

                        All data access should be done through a data access layer in a properly stratified design

                        Correct. And, using stored procs can help do this. How much code do you see on the web where people type SQL right into aspx files, for example ?

                        John Cardinal wrote:

                        There are many *many* things you can not do with stored procedures that you can easily do in code.

                        How is this possible, when a stored proc is just a bunch of SQL ? Name 3.

                        John Cardinal wrote:

                        There is little or nothing you can do to protect your intellectual property when it's in plain sight in the database in stored procedures.

                        If you're writing a C++ app, this is true. Assuming someone has access to your SQL Server, they can see your SQL.

                        John Cardinal wrote:

                        There is no security issue with using dynamic sql as long as you know what you are doing.

                        It's true that dynamic SQL doesn't guarentee security issues, but it does remove the easiest way to add security - the logged in user should only be allowed to call stored procs.

                        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                        C Offline
                        C Offline
                        Chris Meech
                        wrote on last edited by
                        #24

                        Christian Graus wrote:

                        1 - stored procs are precompiled

                        Some DB's cache compiled SQL, so under specific circumstances a query can appear to be just as performant as a stored proce because the execution plan has been cached.

                        Christian Graus wrote:

                        stored procs lower the amount of network traffic required to make a request

                        This is one area that a stored proc will always shine. However, if need be a separate server process, ie. a local server program, can replace the stored proc, but how it becomes invoked will depend upon factors built into that process. But I'm of the mind that says, rules carved in stone just require a bigger hammer. :)

                        Chris Meech I am Canadian. [heard in a local bar] I agree with you that my argument is useless. [Red Stateler] Hey, I am part of a special bread, we are called smart people [Captain See Sharp] The zen of the soapbox is hard to attain...[Jörgen Sigvardsson] I wish I could remember what it was like to only have a short term memory.[David Kentley]

                        1 Reply Last reply
                        0
                        • M Miszou

                          I've just recieved an email from my supervisor, asking me not to use any server-side functions, stored procedures, views or queries and to keep all database coding within the code itself - just in case we need to change databases or sell to a client that doesn't use the same database that we do. We write in-house web apps (classic ASP and C#) using SQL Server 2000 and have so far sold a total of zero applications to third parties (We are not a software house - just a small IT department serving the rest of the company). Pseudo-code for the offending stored procedure that prompted the new policy is shown below: begin insert data into table select scope_identity() as userid end I was instructed to change it to two separate calls from within the code: recordset.open( "insert data into table" ) ... recordset.open( "select @@identity" ) Any thoughts? I have mine, but I'd be interested in hearing from others...


                          The StartPage Randomizer | The Timelapse Project | A Random Web Page

                          M Offline
                          M Offline
                          Marc Clifton
                          wrote on last edited by
                          #25

                          Miszou wrote:

                          Any thoughts?

                          I mostly think that your supervisor's views (no pun intended) are insane. If you change DB's and all the database coding is in the code itself, you'll most likely end up needing to change the code as well. However, the DB isn't the best place for abstraction either. What you really need is a layer of abstraction between the DB and your app that defines the interface for what you're doing. Then a concrete layer to handle the specifics of the target DB. It's the concrete layer that implements the abstraction that should be exchangeable to handle the quirks of a different DB.

                          Miszou wrote:

                          I was instructed to change it to two separate calls from within the code: recordset.open( "insert data into table" ) ... recordset.open( "select @@identity" )

                          Well, I'm no fan of hardwiring the code to a particular schema either, as changes to the schema require changes to the code. As a result, I much prefer auto-generated SQL as much as possible. I also don't like having the DB generate the ID for me. I use GUID's for primary key values and I hook the new row event and populate the ID before the DB even sees the transaction. That way, I can update the primary table and foreign tables [edit]independent of the DB even getting involved[/edit] then send all the transactions at once (and rollback also if necessary). But then again, some may say my approach is equally insane. :) So, fundamentally, if your boss is trying to make an application that is DB-agnostic, I think he has to go a lot further than declaring that all DB related stuff should be in the code itself. That'll probably make the problem worse, not better. Marc

                          Thyme In The Country

                          People are just notoriously impossible. --DavidCrow
                          There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer
                          People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith

                          R 1 Reply Last reply
                          0
                          • M Miszou

                            I've just recieved an email from my supervisor, asking me not to use any server-side functions, stored procedures, views or queries and to keep all database coding within the code itself - just in case we need to change databases or sell to a client that doesn't use the same database that we do. We write in-house web apps (classic ASP and C#) using SQL Server 2000 and have so far sold a total of zero applications to third parties (We are not a software house - just a small IT department serving the rest of the company). Pseudo-code for the offending stored procedure that prompted the new policy is shown below: begin insert data into table select scope_identity() as userid end I was instructed to change it to two separate calls from within the code: recordset.open( "insert data into table" ) ... recordset.open( "select @@identity" ) Any thoughts? I have mine, but I'd be interested in hearing from others...


                            The StartPage Randomizer | The Timelapse Project | A Random Web Page

                            M Offline
                            M Offline
                            mondog2k5
                            wrote on last edited by
                            #26

                            In the end anything is possible. I think that you may want to look as some type of abstraction to the process; like SubSonic at CodePlex, etc. But my spider sense would wonder if the manager knows of some kind of buyout or something. Remember what sounds good in marketing does not always work well in like. So, if he can say that the database is agnostic then that’s a selling point. My suggestion - look for something that will make your like easy and fulfills your managers demands and at the same time update your resume.

                            1 Reply Last reply
                            0
                            • M Member 96

                              Stored procedures should never be used in a commercial software application. 1) Performance is not noticeably better to the end user. That used to be true a very long time ago supposedly, I don't know from personal experience because I wasn't databasing in the 70s and 80's. I can testify without a shadow of a doubt that it is no longer true for FireBird, MS SQL server or Oracle. I had a major app that was targetted exclusively at MS SQL server, about halfway through development we came to our senses and decided to target different databases, I personally have benchmarks and a lot of experience converting the app to DAL and there is no question that the end user will never see a difference in peformance either way. 2) All data access should be done through a data access layer in a properly stratified design, i.e. presentation layer, business object layer, data access layer (and usually more in between). This gurantees portability, forcing your end user into a particular database brand when it's easy to write an independant DAL for different DB's is just stupid. 3) There are many *many* things you can not do with stored procedures that you can easily do in code. 4) There is little or nothing you can do to protect your intellectual property when it's in plain sight in the database in stored procedures. 5) There is no security issue with using dynamic sql as long as you know what you are doing. I agree completely with your boss on the first part, on the second part about inserting a record adn retreiving it's unique id that's completely wrong for dynamic sql, instead generate the ID's at the application and insert the record in one trip. We use Guid's for that exactly to avoid the whole server generated identity trap.

                              M Offline
                              M Offline
                              Michael P Butler
                              wrote on last edited by
                              #27

                              John Cardinal wrote:

                              Stored procedures should never be used in a commercial software application.

                              How are you defining commercial software? I sell business solutions and have used SPs for donkeys years and never had a single issue.

                              John Cardinal wrote:

                              1. All data access should be done through a data access layer in a properly stratified design, i.e. presentation layer, business object layer, data access layer (and usually more in between). This gurantees portability, forcing your end user into a particular database brand when it's easy to write an independant DAL for different DB's is just stupid.

                              That makes sense, but it doesn't preclude using SPs on the database.

                              Michael CP Blog [^] Development Blog [^]

                              M 1 Reply Last reply
                              0
                              • C Christian Graus

                                I agree - for the same reason, no application should ever use the registry, or have a config file. I mean, those pesky end users, they can never be trusted, or educated, for that matter.

                                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                                P Offline
                                P Offline
                                PIEBALDconsult
                                wrote on last edited by
                                #28

                                Not sure whether or not you're being facetious, but I'll drink to that anyway. The registry is evil.

                                1 Reply Last reply
                                0
                                • M Member 96

                                  Stored procedures should never be used in a commercial software application. 1) Performance is not noticeably better to the end user. That used to be true a very long time ago supposedly, I don't know from personal experience because I wasn't databasing in the 70s and 80's. I can testify without a shadow of a doubt that it is no longer true for FireBird, MS SQL server or Oracle. I had a major app that was targetted exclusively at MS SQL server, about halfway through development we came to our senses and decided to target different databases, I personally have benchmarks and a lot of experience converting the app to DAL and there is no question that the end user will never see a difference in peformance either way. 2) All data access should be done through a data access layer in a properly stratified design, i.e. presentation layer, business object layer, data access layer (and usually more in between). This gurantees portability, forcing your end user into a particular database brand when it's easy to write an independant DAL for different DB's is just stupid. 3) There are many *many* things you can not do with stored procedures that you can easily do in code. 4) There is little or nothing you can do to protect your intellectual property when it's in plain sight in the database in stored procedures. 5) There is no security issue with using dynamic sql as long as you know what you are doing. I agree completely with your boss on the first part, on the second part about inserting a record adn retreiving it's unique id that's completely wrong for dynamic sql, instead generate the ID's at the application and insert the record in one trip. We use Guid's for that exactly to avoid the whole server generated identity trap.

                                  A Offline
                                  A Offline
                                  Andy Brummer
                                  wrote on last edited by
                                  #29

                                  The one reason I like stored procedures is that when you are setting up indexes for the database you can view all the sql that will be run against the database before hand. With everything in application code at the very least you have to look in code to do the same thing, but commonly you have to actually run the application and profile it to see what sql is being executed against the database. It doesn't make that much difference for small apps, but when you have large applications with dbas and developers on seperate teams, which are on a different team then the opperational dba that would be the guy to collect the profile info, it can make things much easier. In the end there isn't that much difference between using and not using stored procedures, the biggest issue is managing the flow of data across the network effectively.


                                  I can imagine the sinking feeling one would have after ordering my book, only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon

                                  1 Reply Last reply
                                  0
                                  • C Christian Graus

                                    John Cardinal wrote:

                                    Stored procedures should never be used in a commercial software application.

                                    Wow....

                                    John Cardinal wrote:

                                    Performance is not noticeably better to the end user.

                                    I guess that depends. How can you claim that it never is when 1 - stored procs are precompiled 2- stored procs lower the amount of network traffic required to make a request

                                    John Cardinal wrote:

                                    All data access should be done through a data access layer in a properly stratified design

                                    Correct. And, using stored procs can help do this. How much code do you see on the web where people type SQL right into aspx files, for example ?

                                    John Cardinal wrote:

                                    There are many *many* things you can not do with stored procedures that you can easily do in code.

                                    How is this possible, when a stored proc is just a bunch of SQL ? Name 3.

                                    John Cardinal wrote:

                                    There is little or nothing you can do to protect your intellectual property when it's in plain sight in the database in stored procedures.

                                    If you're writing a C++ app, this is true. Assuming someone has access to your SQL Server, they can see your SQL.

                                    John Cardinal wrote:

                                    There is no security issue with using dynamic sql as long as you know what you are doing.

                                    It's true that dynamic SQL doesn't guarentee security issues, but it does remove the easiest way to add security - the logged in user should only be allowed to call stored procs.

                                    Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

                                    M Offline
                                    M Offline
                                    Member 96
                                    wrote on last edited by
                                    #30

                                    Christian Graus wrote:

                                    I guess that depends. How can you claim that it never is when 1 - stored procs are precompiled 2- stored procs lower the amount of network traffic required to make a request

                                    I said *noticeably* different. If we forget entirely and conveinently the fact that execution plans are cached on most database servers now regardless of whether they came from dynamic sql or sp, we're talking maybe 10 seconds total over the entire course of day. Stored procedures do *not* reduce network traffice, well designed queries do.

                                    Christian Graus wrote:

                                    How is this possible, when a stored proc is just a bunch of SQL

                                    Because you can write the sql dynamically in your code as your application is running, there are many areas you can take advantage of this when you are not fettered by set in stone stored procedures, I use it for filtering and sorting in a 3rd party datagrid that has complex filtering built into it that isn't sql friendly, I use it for very performant knowledgebase type searching, complex reporting.

                                    Christian Graus wrote:

                                    John Cardinal wrote: There is little or nothing you can do to protect your intellectual property when it's in plain sight in the database in stored procedures. If you're writing a C++ app, this is true. Assuming someone has access to your SQL Server, they can see your SQL.

                                    Well my primary concern here is that I don't want my well meaning end users to go messing about with the stored procedures which they will do on their own given an easy opportunity to do so, but secondarily since my logic is primarily in my source code and it's obfuscated it's harder to get at that in the end which is all we can really do.

                                    C C 2 Replies Last reply
                                    0
                                    • M Member 96

                                      I guess anything is possible, I've never seen it be the case in practice, my apps are business apps and make *extreme* use of the power of the database engine itself and I've tested and timed and profiled with all manner of different queries and back end databases when I was researching going to a data access layer a couple of years ago and I could never find a perceptible difference between dynamic and stored procedure. Something which a lot of people said would be the case despite the common belief that stored procedures are always faster. I'm kinda intense on this issue :) and any other issue involving software development where people have beliefs that aren't validateable in the real world. I think I'm going to publish a "Heretics guide to software development" explaining why Frames are not necessarily a bad thing in web applications, why stored procedures are a bad thing in commercial application design etc etc. I can only imagine the grief people would try to give me! :)

                                      P Offline
                                      P Offline
                                      PIEBALDconsult
                                      wrote on last edited by
                                      #31

                                      Today's heresy is tomorrow's dogma.

                                      1 Reply Last reply
                                      0
                                      • M Member 96

                                        I guess anything is possible, I've never seen it be the case in practice, my apps are business apps and make *extreme* use of the power of the database engine itself and I've tested and timed and profiled with all manner of different queries and back end databases when I was researching going to a data access layer a couple of years ago and I could never find a perceptible difference between dynamic and stored procedure. Something which a lot of people said would be the case despite the common belief that stored procedures are always faster. I'm kinda intense on this issue :) and any other issue involving software development where people have beliefs that aren't validateable in the real world. I think I'm going to publish a "Heretics guide to software development" explaining why Frames are not necessarily a bad thing in web applications, why stored procedures are a bad thing in commercial application design etc etc. I can only imagine the grief people would try to give me! :)

                                        P Offline
                                        P Offline
                                        Pete OHanlon
                                        wrote on last edited by
                                        #32

                                        The attitude that Stored Procedures run quicker is a holdover from older RDBMS systems. Most decent RDBMS have very sophisticated caching mechanisms that render the differences moot. I've written responses about this in the past, and it is something that I can get quite hot under the collar about. What I will argue is that you should never render your dynamic SQL via something like:

                                        string sql = string.Format("insert into mytable values ('{0}')", name);
                                        

                                        This opens up all sorts of security holes - but by using proper parameters then you can get past this quite nicely.

                                        the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
                                        Deja View - the feeling that you've seen this post before.

                                        M 1 Reply Last reply
                                        0
                                        • M Member 96

                                          James R. Twine wrote:

                                          Not really - we have had little utilities like strings for quite some time now. If you have enough permissions to launch the application, you have enough to dump the binary into an editor and/or get the strings out of it. Unless you encode the strings in some manner, they are in the binary in plaintext.

                                          I can't tell you the number of clients over the years that have messed with databases that we include with our software. They see it, have a little experience and want to mess with it. Stored procedures are easily messed with by end users, dynamic sql isn't. The number one security threat for commercial software developers is protecting users from themselves, external threats are a distant second.

                                          C Offline
                                          C Offline
                                          Chris Meech
                                          wrote on last edited by
                                          #33

                                          John Cardinal wrote:

                                          Stored procedures are easily messed with

                                          You've never had to code in PL/SQL from Oracle, I'd reckon. :)

                                          Chris Meech I am Canadian. [heard in a local bar] I agree with you that my argument is useless. [Red Stateler] Hey, I am part of a special bread, we are called smart people [Captain See Sharp] The zen of the soapbox is hard to attain...[Jörgen Sigvardsson] I wish I could remember what it was like to only have a short term memory.[David Kentley]

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups