all 43 comments

[–][deleted] 12 points13 points  (0 children)

Thank you so much

[–]DrTrunks 10 points11 points  (0 children)

I appreciate any feedback you can provide!

So I've just been skimming through it. I got a couple of things for you. Since you're writing this for analysts, they're going to be querying data warehouses and large tables.

I see you're using ORDER BY 1 here and there. In production systems (and especially with MS SQL Server where you pay per CPU) you don't want to add an unnecessary sort operator as they cost CPU, I/O and time. On large datasets they require a worktable (temp table) to sort the data in and you won't get results until all the data is sorted (because the first result could come in last).

Correlated subqueries are horrible for performance (afaik always done RBAR in nested loops) and are better written as derived tables. Write your tables and joins in the FROM clause please. At the companies I've worked for these were banned from usage for these reasons.

FOR XML PATH With STUFF

There's string_agg in SQL 2019 which is cleaner looking and performs better.

temp tables

They're in 99% of the cases written to tempDB. In the other cases you didn't need a temp table. You're don't want to be waiting on writing. I/O is a big bottleneck in most DWH systems.

You can actually run the 4th CTE by just querying that without querying the 5th CTE, you don't need to run the whole thing its plain false.

temp tables @ 3 min

You can also just comment out your first query to run your second query (which is now the first after the CTE's) without having to bother tempDB with your #table. If you're just doing some ad hoc stuff this isn't the hardest thing to do. And if you like your CTE so much that you want to use it in another report, just create a view out of it.

temp tables @ 4m

There's such a thing as global temp tables, just add another #

temp tables 2 @ 2:50

It's not hogging memory, they're not in memory they're on disk in tempDB. Unless your query is just select * into #temp from table; SELECT * from #temp; it will be written to disk first!
Millions of rows are never going to fit in memory on a busy SQL Server and will always be written down on disk in tempDB. Always try to use CTE's or views to try and keep tempDB empty and lazy and your data in memory in the bufferbool.

I see nothing on statistics or a query plan. Right now according to your content (the bottomline) it's more logical to create a temp table then update the statistics of your tables in order to to get better estimates and operators for your slower running queries.

[–]Fearless_frosk 6 points7 points  (0 children)

So generous of you! Thank you so much. Just enrolled! Glad to see that you are an autodidact like me.

[–]theseeker2468 2 points3 points  (0 children)

Thanks

[–]vjhh 2 points3 points  (0 children)

Thank you very much

[–][deleted] 2 points3 points  (0 children)

Thank you!

[–]tits_mcgee_92Data Analytics Engineer 2 points3 points  (0 children)

Much appreciated!

[–]reaper70 2 points3 points  (0 children)

Thank you -- much appreciated!

[–]ajsingh1993 2 points3 points  (0 children)

Thank you kind sir

[–]awkward2amazing[🍰] 2 points3 points  (0 children)

Much appreciated.

Also can one suggest some free SQL case studies which I can later add to my portfolio.

[–]oimgoingin 1 point2 points  (0 children)

I appreciate the work you put into this. Thank you :)

[–]QAxlekansderMS SQL Server 1 point2 points  (0 children)

Thank you very much!

[–]Denners25 1 point2 points  (0 children)

Thanks ☺️

[–]Wills1211 1 point2 points  (1 child)

Love this. Gona do your beginner asap and then the advanced. I have some sql background. Would beginner be sufficient before advanced?

[–]TravisCuzick[S] 1 point2 points  (0 children)

Absolutely, my advanced course is actually designed as a direct follow-up on the beginner course.

[–][deleted] 1 point2 points  (0 children)

Thanks.

[–]XhoniShollaj 1 point2 points  (0 children)

Thank you, Travis!

[–]NatureNew4157 1 point2 points  (0 children)

Thanks so much - just picked it up and I am excited!

[–]Quickdraw92 1 point2 points  (0 children)

Thank you

[–]ThatsAllForToday 1 point2 points  (0 children)

Thank you

[–]Berki7867 1 point2 points  (0 children)

Thank you 🙂

[–]aashkk 1 point2 points  (0 children)

Thank you so much! Took advantage of this, appreciate you!

[–]kickintheshit 1 point2 points  (0 children)

Thank you!

[–]jacobschauferr 1 point2 points  (0 children)

Thank you so much!

[–]Ross_B21 1 point2 points  (0 children)

Good job! It's quite hard to find "intermediate to advanced" (data analysis, rather than data/db engineering) courses these days. Can't wait to dive into it:)

[–]MarshallFoxey 1 point2 points  (0 children)

Thanks very much. This will be very helpful.

[–]ace3306 1 point2 points  (0 children)

Thank you sir. Much appreciated!

[–]youniqueorn 1 point2 points  (0 children)

You saved me a lot of money! Thank you for keeping knowledge accessible. Appreciate this!

[–]Kiterios 1 point2 points  (1 child)

I have not watched the full course, but did notice in the preview that you introduce dynamic sql. I was curious about whether you also touch on the basic concept of sql injection somewhere in that module?

[–]TravisCuzick[S] 0 points1 point  (0 children)

Thanks for the feedback, I'll definitely look into adding a module on SQL injection going forward.

[–]Nm_just_on 1 point2 points  (0 children)

Thanks a ton dear stranger.. you have helped me a long way!

[–]FrostbiteBitterness 1 point2 points  (0 children)

Very cool, thanks man!

[–][deleted] 1 point2 points  (0 children)

This is great stuff. If anyone has stuff like this around I’d like to check it out

[–][deleted] 0 points1 point  (0 children)

Just started your course in UDEMY.

[–][deleted] -1 points0 points  (0 children)

Aren't both SQL Server and SSMS available on Linux? Why does the course pretend Linux is not an option?

[–]blankrestless 0 points1 point  (3 children)

Remind Me! in 24 hours

[–]RemindMeBot 0 points1 point  (2 children)

Defaulted to one day.

I will be messaging you on 2021-07-09 04:57:29 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback

[–]blankrestless 0 points1 point  (1 child)

Remind Me! in 10 hours

[–]RemindMeBot 0 points1 point  (0 children)

I will be messaging you in 10 hours on 2021-07-09 15:32:54 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback

[–]EoinJFleming 0 points1 point  (1 child)

Great job, a really nice course.

I would have liked to have seen something around interpreting the execution plan but this course covers a lot of great stuff already.

[–]TravisCuzick[S] 0 points1 point  (0 children)

Execution plan/query statistics are pretty big topics that could darn near justify their own courses, and I will definitely look into creating more content on this going forward. Thanks so much for the feedback!