Stored Procedures are Better than Raw SQL

Поділитися
Вставка
  • Опубліковано 11 гру 2024

КОМЕНТАРІ • 18

  • @PeteSimpson
    @PeteSimpson 2 роки тому +5

    The biggest advantage of stores procedures from my perspective is that sometimes I have to create extremely long and complicated historical queries from multiple tables. If I just used queries from directly within the application, retrieving certain data can easily take 8 to 10 seconds, but using a stored procedure can easily cut that time down to less than a second. The above is an actual example that I came across a few years ago, and yes I was using Index as well.
    I don't always use stored procedures as in certain scenarios I prefer direct app access. But for large complicated queries (usually historical) I always stored procedures.

    • @DatabaseStar
      @DatabaseStar  2 роки тому +1

      Great example! Thanks for sharing. Good to hear it’s not something you necessarily use all the time but that they have their purpose.

  • @marcello4258
    @marcello4258 Рік тому +1

    Con 3:
    You usually always have, as you pointed out, specific non standard sql in complexe apps anyway. Triggers are also on top of that. So I guess rewriting the stored procedures only add up a very tiny bit on it. We migrated from oracle to snowflake and didn’t had any stored procedures and it took us a full year. I guess the stored procedures if they would have been present would have added just one week by one person. In total 5 people were involved on and off in the year.

    • @DatabaseStar
      @DatabaseStar  Рік тому +2

      That's a good point and thanks for sharing your experience!

    • @marcello4258
      @marcello4258 Рік тому

      @@DatabaseStar thanks for taking time making high quality content!

  • @georgeblazhev
    @georgeblazhev 8 місяців тому +1

    About version control, there are libraries that help automating the process of applying migrations, so you can have a solution that keeps the sql files and you can track the commits and automate the migrations across different environments with a proper CI/CD pipeline. I was very against stored procedures but I'm coming to seeing their value and advantages the more experience I gain

    • @DatabaseStar
      @DatabaseStar  8 місяців тому +2

      Great point about version control! Good to hear about your experience as well

  • @icns01
    @icns01 5 місяців тому +1

    A really good primer of Stored procedures. Much appreciated 👍

  • @hasanmougharbel8030
    @hasanmougharbel8030 2 роки тому +1

    Hey there,keep up the great work in your channel.
    I have only a general enquiry as a newbie sql learner.
    Could i channel shopify live data into an sql application?(This should be an application developed for a company of 50 employees mainly for the sake of generating reports and analytics))
    Is this an easy process to undertake as a sql beginner? What should i keep in mind
    and what are the tools or softwares that i should work with right from the beginning.
    For notice, I made my mind to work with microsoft sql server, also our company has a dedicated server.
    Thanks for taking care of my enquiry.

    • @DatabaseStar
      @DatabaseStar  2 роки тому +1

      Good question! I'm not sure how you would get the live Shopify data into an SQL database. You may need to research how to get that data. If you can download it somehow, you can import it into a database and run analysis on that.

  • @rayvid7979
    @rayvid7979 16 днів тому

    based on my personal experience... SP remains the best way to get the most out of your database. And I still have tolerance for those who put their SQL on their middle tier apps as long as they are not using ORM.

    • @DatabaseStar
      @DatabaseStar  15 днів тому

      Thanks for sharing! Yes, stored procedures can be pretty useful!

    • @rayvid7979
      @rayvid7979 14 днів тому

      @DatabaseStar please do a video about stored procedure vs ORM. Which one do you think is more superior?

  • @moldirshynggys2841
    @moldirshynggys2841 7 місяців тому

    very useful! thanks!

  • @oracle_professor
    @oracle_professor 2 роки тому

    Very Nice Tip