The Top 10 Developer Mistakes That Won't Scale on Microsoft SQL Server

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

КОМЕНТАРІ •

  • @lollo4711
    @lollo4711 3 роки тому +1

    a.) "Select *" - YEARS AGO: Developing VB6 (using ODBC, DAO, OLEDB, etc.) it was said that it´s better/faster to use "SELECT *" because database just returned a cursor (dep. on Recordset-Type).
    b.) "more sort space required" - I let clients use their CPU-Power to sort (defining query with SORT also gives me warnings).
    PS: always searched for this kind of deeper information on SQL Server! Lucky to have found it! appreciate!

  • @Zoltag00
    @Zoltag00 4 роки тому

    I heard your bit about OPTION RECOMPILE being slapped everywhere and it made me lol. Unfortunately it also reminded me of one of my colleagues, who insists on putting SET TRANSACTION ISOLATION LEVEL REPEATABLE READ at the top of every sproc reading from the DB and SET TRANSACTION ISOLATION LEVEL SERIALIZABLE at the top of every sproc writing to the DB

  •  Рік тому

    In a datawarehouse schemas are quite useful to limit access for certain reporting tools or exports.

  • @MeirbhinOConaill
    @MeirbhinOConaill 4 роки тому +2

    Thank you for these videos. I'm currently rebuilding a query that parsed XML to a table variable. I did not think to check that logic vs temp tables. Thank you very much good sir

  • @Dmitriy.0
    @Dmitriy.0 4 роки тому +3

    DJ Khaled: "Those are nice columns you got there. Would be a shame if someone added ANOTHER ONE!"

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

    I agree with most of what you say, and I learned a lot from you. Yet, I do not totally agree about triggers though. Triggers are life savers, even at the cost of performance when well and correctly used. But they should be built from the bottom up to be effective. They should be an integral part of the total solution, and not just an 'add-on' or 'quick-fix'. Regarding the example you gave about triggers means the whole database logic is incorrect since its inception.
    Unlike what people think, the database is the heart of any data system, in the end, we all use and communicate with data. 'Code first' is a bad example of data structuring. That new trend of two weeks/iteration (DevOps/Agile/Stuff) is a kill for building a sound and robust system, as you are burning steps and skipping security and performance. Finally, as you said earlier, whenever I am interviewing someone, I also tend to find out how they map their web application to the database, and guess what, 99% are use 'sa' user and I guess their password is 'sa' too :)

  • @maikelvangorkom
    @maikelvangorkom 3 роки тому +1

    It's not only the amount of columns using select *, but also what's in the columns. Once had a guy ask why his qury was slow with only 3 columns and 3 records. After some checking, i found that he had 1 blob column, with isos, so he read only 3 records, but also on average 3GB per record. So still love getting only the columns you need.

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

    Having watched this, I have greater respect for my DBA

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

    What about taking those Table Variables and putting them into a bunch of 'WITH' nested CTEs contained within a Multi-Statement Table Function? 🤔
    Orrrr...should I just chuck those tables into a view
    orrrr.....would I just do better using temp tables from the SP itself?

  • @Meuhrlin
    @Meuhrlin 4 роки тому

    We use DACPACs to deploy on a daily basis as part of our DevOps and BIOps process and we have not seen the issue of tables being deleted and recreated as described here. We do however notice that DACPACs are very picky and the slightest difference in definition will trigger a rebuild of the object (always block if data loss might occur). We do work on SQLServer 2016+.
    What we do is build our solution (even for BI) in Visual Studio and always deploy from the project build, making sure that what we do is consistent over time. We try to do EVERYTHING in the project, not in SSMS. This is probably why we don't have issues compared to other teams we know who have had such issues but they work mostly in SSMS and just archive SQL scripts and DACPACs are the exception for them.
    Will investigate further.

    • @antoniocortina602
      @antoniocortina602 4 роки тому

      I totatly agree. We've be using SSDT for database development in our projects with great results.

    • @kerwinCarpede
      @kerwinCarpede 4 роки тому

      @@cytwc Use a publish profile and add IgnoreColumnOrder=True or pass in /p:IgnoreColumnOrder=True

    • @MiningForPies
      @MiningForPies 3 роки тому

      @@cytwc never had an issue using them, never had a table drop.

  • @ismamad
    @ismamad 4 роки тому +5

    Who is another C# Developer that likes T-SQL optimization but without being insane on it ?

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

      What kind of developer doesn’t get insane about some things?

  • @databasetales3562
    @databasetales3562 4 роки тому +1

    We get the varchar(max) for ALL and no primary keys thing all the time. I remember a developer arguing that a UNION ALL was faster than joining tables... maybe its just me :)

  • @tsilb
    @tsilb 4 роки тому

    Oh I'm all about the DACPACs. I wish they'd make them suck less though. That import wizard needs all the SqlPackage options.
    Other than DACPACs, what is the "best" way to make sure your production database is in sync with your idea of what it "should" look like?

    • @TheBrentOzar
      @TheBrentOzar 4 роки тому

      For general questions, your best bet is a Q&A site like dba.stackexchange.com.

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

    hey-hey...a fellow 'The Prodigy' fan...nice

  • @eliashdez
    @eliashdez 4 роки тому

    hi Brent, great talk as always, however I have an off topic question, which mic are you using? Its quality is awesome, want to pick one for my online meetings.

    • @TheBrentOzar
      @TheBrentOzar 4 роки тому

      Thanks! It's a DPA d:fine broadcaster headset. (Beware: they're about $1,000.)

    • @PaulSebastianM
      @PaulSebastianM 4 роки тому

      @@TheBrentOzar Kind of pops most of the time though. What happened? You lost your pop filter for it or you don't like how it looks with it on?

    • @TheBrentOzar
      @TheBrentOzar 4 роки тому

      @@PaulSebastianM I totally forgot about it, actually! Should throw that back on. Thanks for reminding me!

  • @PaulSebastianM
    @PaulSebastianM 4 роки тому +2

    As far as I'm concerned, unless you need really large storage, SSDs are better for data, not just for tempdb. Even cheaper enterprise SATA SSD is better than HDD. Even RAID-1/10 consumer SSD in my experience tends to be faster and safer than HDD.

  • @kerwinCarpede
    @kerwinCarpede 4 роки тому

    Awesome talk!

  • @andrewp7497
    @andrewp7497 4 роки тому +2

    The issue with EF is again people not knowing how to write good EF so you are in the same situation. Things like making them virtual and then making multiple calls when one would do, including just the columns you need. I have seen so may badly written EF queries that would be so much cleaner done in just SQL, so in my experience EF creates a mases of rubbish over complicated queries. If people are using EF then they should really know SQL. A strange divide you are talking about as a developer we do all the layers, many companies wont have a dba.If devs dont know SQL then maybe they just shouldn't even touch ORM's!

    • @BrentOzarUnlimited
      @BrentOzarUnlimited  4 роки тому +2

      This is just my opinion, but I think if a developer isn't trained on either T-SQL or EF, but they're using .NET to build their app, then they'll build a better app, faster, by just trying to learn one tool (EF).
      I wish everybody had an unlimited amount of training time to get to know every one of their tools, but that's just not realistic.

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

      EF/ORMs is a nightmare at times. My job is performance tuning across the whole system spectrum from hardware, apps and SQL etc. for the last 30 years and EF has caused so many problems in anything above a simple database that I give warnings all the time about making sure the developers using it know SQL also. Many don't even know SQL is a maths/set based language and that just applying standard structured programming techniques gets you into all sorts of problems. There is the possibility of being able to call SPs from within EF which can get you around some tricky SQL issues (e.g. compile timeouts due to crazy large EF generated SQL) or getting the devs to split up the EF code to make the gen SQL smaller and avoid the timeouts. The lack of a good DBAs guidance is definitely the cause of a lot of EF problems.

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

      @@BrentOzarUnlimited I have actually seen whole projects die on the alter of EF to such an extent that they were totally rewritten within 2 years - it's performance was such a mess.

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

      But you can't learn EF without understanding what is actually happening in the background..
      I am currently also struggling with EFs performance. But not because EF writes bad queries, but because I am requesting data that takes a long time to be assembled and delivered.
      I am now beginning to understand performance tuning, and there are a lot of things you can, do outside of EF, to improve performance. Also a lot of your points apply to EF and can be implemented there aswell

  • @abramswee
    @abramswee 3 роки тому

    Fantastic insight! Thanks for sharing

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

    great ep

  • @vladimirs7052
    @vladimirs7052 4 роки тому

    In what case would you consider table variable a reasonable solution?

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

      There are (almost only) two reasonable reasons for table variables:
      a) you are using BEGIN TRANSACTION / COMMIT or ROLLBACK and want to prevent some logging stuff from being rolled back -> write it into a @table_variable
      b) you need to pass stuff from one procedure to another -> create a table variable type and use it a parameter. On the other hand you could either use a regular (in memory schema only) table for this purpose too. Or even a string list, if you just need to pass a bunch of id's.

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

    Did I miss the discussion about how bad UDFs are? 🤔

  • @luisvibranovski4801
    @luisvibranovski4801 4 роки тому

    Hi Brent, great video! I have a question about indexes on new tables: You said that you create only indexes on PK, right? But how about the indexes on the other side of the foreign keys, don't you create them when you create the FK? Thanks in advance!

    • @BrentOzarUnlimited
      @BrentOzarUnlimited  4 роки тому +1

      Luis - I don't do Q&A here in UA-cam comments. For Q&A, feel free to join during one of my Office Hours sessions. Thanks!

  • @MiningForPies
    @MiningForPies 3 роки тому

    I’m using dacpacs in production, never needed to drop a database to update 🤔

    • @TheBrentOzar
      @TheBrentOzar 3 роки тому

      I don't believe I said drop a database - I said drop a *table*. Big difference. Try refactoring two columns into one (or vice versa), for example.

    • @MiningForPies
      @MiningForPies 3 роки тому

      @@TheBrentOzar you say they would create a new database and copy everything to it, guess it was a slip of the tongue. Either way, never had an issue with tables being dropped either 🤔

    • @TheBrentOzar
      @TheBrentOzar 3 роки тому

      @@MiningForPies oh yeah, for serious deployment changes, yeah. You might just be doing more simplistic changes, like only adding columns rather than refactoring or removing them.

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

    What if identity col expired ? Reached its limit

    • @BrentOzarUnlimited
      @BrentOzarUnlimited  11 місяців тому

      I wouldn't say that's a top mistake - it's fairly easy to fix by starting again with negative numbers, and then switching to bigints.

  • @hajeraabdullah9157
    @hajeraabdullah9157 4 роки тому

    out of curiosity why do you wear a cap?

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

    still a great video. "I'm a butthole" hahha

  • @photukumar8323
    @photukumar8323 4 роки тому

    Nice video

  • @RaymondPorrata
    @RaymondPorrata 4 роки тому +1

    Radio Shack CAT!

  • @tetsballer1835
    @tetsballer1835 8 місяців тому

    I have 8 10GB temp dbs :)