- 456
- 395 371
Erik Darling (Erik Darling Data)
United States
เข้าร่วมเมื่อ 4 ม.ค. 2019
SQL Server stuff. Like and subscribe.
If you like what you see here, you'll love my advanced performance tuning training:. This link will get you 75% off your order:
training.erikdarling.com/?coupon=SPRINGCLEANING
If you like what you see here, you'll love my advanced performance tuning training:. This link will get you 75% off your order:
training.erikdarling.com/?coupon=SPRINGCLEANING
The State Of Table Variables In 2025
Become a member! www.youtube.com/@ErikDarlingData/join
Ask me questions! go.erikdarling.com/OfficeHours
Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK
If you like what you see here, you'll love my advanced performance tuning training:
training.erikdarling.com/?coupon=SPRINGCLEANING
Ask me questions! go.erikdarling.com/OfficeHours
Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK
If you like what you see here, you'll love my advanced performance tuning training:
training.erikdarling.com/?coupon=SPRINGCLEANING
มุมมอง: 430
วีดีโอ
A Fun Plan Shape With Aggregates
มุมมอง 2752 ชั่วโมงที่ผ่านมา
Become a member! www.youtube.com/@ErikDarlingData/join Ask me questions! go.erikdarling.com/OfficeHours Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK If you like what you see here, you'll love my advanced performance tuning training: training.erikdarling.com/?coupon=SPRINGCLEANING Paul White's blog post: www.sql.kiwi/2010/07/the-seg...
When Subquery Query Plans Are Suboptimal In SQL Server (And How To Fix Them)
มุมมอง 4034 ชั่วโมงที่ผ่านมา
Become a member! www.youtube.com/@ErikDarlingData/join Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK If you like what you see here, you'll love my advanced performance tuning training: training.erikdarling.com/?coupon=SPRINGCLEANING
The Great Integer To Bigint Compression Swindle
มุมมอง 71612 ชั่วโมงที่ผ่านมา
Become a member! www.youtube.com/@ErikDarlingData/join Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK If you like what you see here, you'll love my advanced performance tuning training: training.erikdarling.com/?coupon=SPRINGCLEANING Andy's post: am2.co/2019/12/changing-a-column-from-int-to-bigint-without-downtime/
Indexing SQL Server Queries For Performance: Computed Columns
มุมมอง 44214 ชั่วโมงที่ผ่านมา
Become a member! www.youtube.com/@ErikDarlingData/join Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK If you like what you see here, you'll love my advanced performance tuning training: training.erikdarling.com/?coupon=SPRINGCLEANING
Indexing SQL Server Queries For Performance: Windowing Functions
มุมมอง 74716 ชั่วโมงที่ผ่านมา
Become a member! www.youtube.com/@ErikDarlingData/join Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK If you like what you see here, you'll love my advanced performance tuning training: training.erikdarling.com/?coupon=SPRINGCLEANING
Indexing SQL Server Queries For Performance: Index Sorting
มุมมอง 57919 ชั่วโมงที่ผ่านมา
Become a member! www.youtube.com/@ErikDarlingData/join Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK If you like what you see here, you'll love my advanced performance tuning training: training.erikdarling.com/?coupon=SPRINGCLEANING
Indexing SQL Server Queries For Performance: Indexed Views And Non-SARGable Predicates
มุมมอง 46721 ชั่วโมงที่ผ่านมา
Become a member! www.youtube.com/@ErikDarlingData/join Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK If you like what you see here, you'll love my advanced performance tuning training: training.erikdarling.com/?coupon=SPRINGCLEANING
Indexing SQL Server Queries For Performance: Indexed Views And Filtered Indexes
มุมมอง 532วันที่ผ่านมา
Become a member! www.youtube.com/@ErikDarlingData/join Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK If you like what you see here, you'll love my advanced performance tuning training: training.erikdarling.com/?coupon=SPRINGCLEANING
Indexing SQL Server Queries For Performance: Indexed View Maintenance
มุมมอง 517วันที่ผ่านมา
Become a member! www.youtube.com/@ErikDarlingData/join Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK If you like what you see here, you'll love my advanced performance tuning training: training.erikdarling.com/?coupon=SPRINGCLEANING
Indexing SQL Server Queries For Performance: Blocking and Deadlocking
มุมมอง 59414 วันที่ผ่านมา
Become a member! www.youtube.com/@ErikDarlingData/join Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK If you like what you see here, you'll love my advanced performance tuning training: training.erikdarling.com/?coupon=SPRINGCLEANING
Indexing SQL Server Queries For Performance: Missing Index Requests Are Bad And Dumb
มุมมอง 89514 วันที่ผ่านมา
Become a member! www.youtube.com/@ErikDarlingData/join Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK If you like what you see here, you'll love my advanced performance tuning training: training.erikdarling.com/?coupon=SPRINGCLEANING
Indexing SQL Server Queries For Performance: Eager Index Spools
มุมมอง 75014 วันที่ผ่านมา
Become a member! www.youtube.com/@ErikDarlingData/join Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK If you like what you see here, you'll love my advanced performance tuning training: training.erikdarling.com/?coupon=SPRINGCLEANING
Indexing SQL Server Queries For Performance: Fixing non-SARGable Predicates
มุมมอง 71314 วันที่ผ่านมา
Become a member! www.youtube.com/@ErikDarlingData/join Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK If you like what you see here, you'll love my advanced performance tuning training: training.erikdarling.com/?coupon=SPRINGCLEANING
Indexing SQL Server Queries For Performance: Predicate Key Lookups
มุมมอง 62314 วันที่ผ่านมา
Become a member! www.youtube.com/@ErikDarlingData/join Click here for 50% off a health check: training.erikdarling.com/darling-data-health-check?coupon=HEALTHCHECK If you like what you see here, you'll love my advanced performance tuning training: training.erikdarling.com/?coupon=SPRINGCLEANING
Indexing SQL Server Queries For Performance: Unpredictable Searches
มุมมอง 76921 วันที่ผ่านมา
Indexing SQL Server Queries For Performance: Unpredictable Searches
Indexing SQL Server Queries For Performance: Equality and Inequality Predicates
มุมมอง 87721 วันที่ผ่านมา
Indexing SQL Server Queries For Performance: Equality and Inequality Predicates
How To Write SQL Server Queries Correctly: Literally Everything You Need To Know About OUTPUT
มุมมอง 1.2K21 วันที่ผ่านมา
How To Write SQL Server Queries Correctly: Literally Everything You Need To Know About OUTPUT
How To Write SQL Server Queries Correctly: Literally Everything You Need To Know About CTEs
มุมมอง 1.3K21 วันที่ผ่านมา
How To Write SQL Server Queries Correctly: Literally Everything You Need To Know About CTEs
How To Write SQL Server Queries Correctly: Case Expressions
มุมมอง 1.7K21 วันที่ผ่านมา
How To Write SQL Server Queries Correctly: Case Expressions
How To Write SQL Server Queries Correctly: Joins With OR Clauses Part 2
มุมมอง 89728 วันที่ผ่านมา
How To Write SQL Server Queries Correctly: Joins With OR Clauses Part 2
How To Write SQL Server Queries Correctly: Joins With OR Clauses Part 1
มุมมอง 97528 วันที่ผ่านมา
How To Write SQL Server Queries Correctly: Joins With OR Clauses Part 1
How To Write SQL Server Queries Correctly: Where Clauses With OR In Them
มุมมอง 1.1Kหลายเดือนก่อน
How To Write SQL Server Queries Correctly: Where Clauses With OR In Them
How To Write SQL Server Queries Correctly: Views vs Common Table Expressions
มุมมอง 865หลายเดือนก่อน
How To Write SQL Server Queries Correctly: Views vs Common Table Expressions
How To Write SQL Server Queries Correctly: INTERSECT And EXCEPT
มุมมอง 822หลายเดือนก่อน
How To Write SQL Server Queries Correctly: INTERSECT And EXCEPT
How To Write SQL Server Queries Correctly: UNION and UNION ALL
มุมมอง 919หลายเดือนก่อน
How To Write SQL Server Queries Correctly: UNION and UNION ALL
How To Write SQL Server Queries Correctly: Views vs Inline Table Valued Functions
มุมมอง 939หลายเดือนก่อน
How To Write SQL Server Queries Correctly: Views vs Inline Table Valued Functions
How To Write SQL Server Queries Correctly: Common Table Expressions
มุมมอง 2.9Kหลายเดือนก่อน
How To Write SQL Server Queries Correctly: Common Table Expressions
The always important caveat "outside of New Zealand"
Don't want to face the Wrath of the Jandal
never using table vars, very tricky and very unexpecable in real world applications. it is there on SQL just like that, for no reason! 😅
There are good reasons for them, performance just isn’t one of them.
This becomes even more fun when that int column is also an identity column...
That’s the reason for having to do it - running up against the 2 billion integer limit.
Table variables would so useful if they worked. Imagine if we instead of implicitly sending table data around and checking if it exists and holds something sensible, could just explicitly send it in parameter...but no who needs that...
You mean like a table valued parameter?
Interesting timing on this video. Just today, I rejected a pull request where the developer used a @tableVariable instead of a #tempTable. I did my own comparisons just now between @tableVariables and #tempTables myself similar to your test scenario. What is revealing in the Properties of the final SELECT of the query plan is that the query using the #tempTable has OptimizerStatsUsage available to it whereas the query using the @tableVariable does not. It’s as if the SQL Optimizer is saying “You go figure it out yourself! Good luck!” As for your estimation of 3 rows on your Posts table query, I wonder if there is a cached plan somewhere that is pinning usage of that table to think it has 3 rows for certain JOIN scenarios. As a Dev Manager having DBA and DB Developer experience since SQL Server 2000, I wish Microsoft would just sunset table variables and be done with this nonsense; or maybe under the cover start treating @tableVariables like #tempTables. The dynamically generated #tablename is already there for the @tableVariable in TEMPDB during its usage. 🙄
Yes, that’s a very good way of illustrating the difference. Much easier than the usual assortment of trace flags. I’m not sure what you’re on about with the cached plan stuff. I was using recompile hints.
I find table variables useful mainly for preserving data after a transaction rollback. Otherwise, I prefer temporary tables for their flexibility and performance.
Everyone says this, but I've never seen anyone actually doing it.
@@ErikDarlingData Oh, well, I have in some data warehouse processing. It was useful for identifying conditions that caused errors and logging them after a rollback.
Yeah, that’s about exactly where I’d expect to see it. Good for you on actually following through!
But you need to declare it before opening the transaction or smt right? So you dump the data to declared table variables then to a log if the transaction fails? Still no way of breaking out of a transaction and logging if your code is initially called inside a transaction?
Wow, this is amazing! I can tell a lot of effort went into making this video. I can't wait to see more!
Best video ever
Nice trick with TOP (1)
Thanks! It’s weird that it’s needed, but here we are.
Got to love the spirit, go Erik go!
Feeling very spiritual over here
I am always astonished that the SQL engine cannot implicitly infer a count aggregate will only ever return 1 row. What do those MS interns do with all their time?
HAHAHA, I keep asking to be in charge of them, but for some reason no one wants me cracking that whip.
I am gonna start following this playlist, any prerequest sir ?
Not really, no.
We have the INT to BIGINT dilemma approaching for a few of our tables. Switching to BIGINT is only the beginning. The real work resides in ensuring we find 100% of the existing INT column references in all the stored procedures, functions, ETL packages, etc. Then full regression testing.
There are probably some programmatic ways to do that within SQL Server, but I’m not sure about the rest of the landscape you have to deal with. Stored procedure parameter data types are all queryable, but if you’re declaring variables or anything you’re pretty well screwed.
This is one reason why I'm glad that int is a 64-bit number in CockroachDB. Also, no SCH lock-waits and PK changes are online and surprisingly fast.
Ooh yeah, I dig some of the stuff they’re doing. Rebecca Taft gave a talk at CMU about it a few years back: th-cam.com/video/wHo-VtzTHx0/w-d-xo.htmlsi=HBg4TGZnj-iLAXxP
I consider this video a pure gold bar, and glitches as mud and dust, which I only need to remove. Or accept.
Ah, yeah, I should revisit some of this stuff from before I had my audio figured out.
Thanks Erik! This was very helpful. On a side note, why do you think Azure and Fabric are not good products?
They’re some of the worst shit ever produced. Would that Microsoft were capable of shame.
Guys that setup GUID's as identity columns spiking the football right now...probably.
Well, who knows what they’re spiking, aside from morning coffee.
"At some point you gotta dance with who brung ya". Just made my day. 😊
I love that phrase!
It is so stupid this isn't a meta-data only change.
It’s a real tooth in my haggis.
Andy's page is the best writeup on shadow table walkovers. Legit awesome stuff.
It's the first time that I've heard of him. What is he good at?
It is! I find myself coming back to it a few times a year.
He's just one of the best presenters and teachers of SQL lore from the past years. and friendly and helpful. He hits the details of an issue and notes caveats. You get "…and here are reasons you might not want to do that" rather than "don't do it" from him. @@FlaggedStar
APPRECIATED
The next year that starts with zero is 2100 or 00
If you put two digit years in a database you deserve everything bad that happens to you.
@@ErikDarlingData I have had to use them in the past, never again. I those days harddisks where expense 500MB = £500.
@@thingTthing yes, I've seen systems like that. Nothing but problems and bugs.
It's always a joy watching Eric make queries so quickly!
🫡🫡🫡
Have a leave, you deserve it ♥
I’ll tree my way out.
Happy Chrismants!
Never too late!
Thanks for the explanation, it was very useful! Sorry to ask, but where may I have access to the script of this video?
Scripts are only available with my paid training content.
For "y_m_Yes_and" , I like to use : Year * 100 + Month
That’s definitely some math.
is columnstore_helper table used in the last query is materialized view or a columnstore index?
It's an empty table with a clustered column store index on it.
I have a question that is outside the scope of this tutorial. When I perform a rebuild of the indexes on the database, its size increases, which is really surprising because I was expecting the database size to decrease. On the other hand, the unallocated space decreased. Any explanation, sir? I have been searching for the right answer, but none has given me a reasonable explanation.
Stop rebuilding indexes. It's a waste of time, unless you're on old spinning disk storage.
@@ErikDarlingData I got you , but you didn't anser my main question it really crucial , could you give me any clue on what's going on ?
@@zahreddinesoualem3213 Because you’ve gotten answers: dba.stackexchange.com/q/344883/32281
@@ErikDarlingData mm so that's is it, thank you so much.
What a trick on that column store helper! 😮
Quite a helpful helper!
4:28 It's funny, I had exactly the same idea. I was wondering how Erik was planning to spend 16 minutes to say "just use batch mode".
I probably should have spoken in batch mode.
A W E S O M E.
😁
i thought you were more of a Misfits guys, but DMX is fun. "InDEX is gunna give it to ya"...ill see myself out
🚪
Do you find using DATA_COMPRESSION = PAGE on indexes has any disadvantages?
Not generally, no. There are times when compression isn’t as effective as others, and heaps are of course their usual strange selves, but I’d rather have it than not most times.
It can cause pain if you're in an environment where you care about your inserts being 0.2 seconds slower.
Hah, good point.
i bit miss that you did nothing else than nonSarg column put on second level. this is pretty funny, because many of us using count distinct to see density of column, but forget about SARGability! thank you for evangelisation in this! 😊
Ah yeah, it can really save you when you're dealing with code you can't change, etc. Thanks for subscribing!
I think I'm going to make an Eric Darling video bingo card: * SQL Server interns * Operator timings making no sense * FORCESEEK * CROSS APPLY trickery * Dislike for OR clauses * Zoomit failing * Batch mode fixing everything * Hints of Postgres supremacy * Paul White worship * The armpit
Well, I'm not quite sure I feel that strongly about Postgres. It has many nice features, and the price is tough to beat. But the query optimizer is nowhere near as good as SQL Server's. I know that must sound strange for as much as I complain about it, but it's true.
😁
almost to 6k.
I can smell it! It smells weird. Like fingers.
@@ErikDarlingData nice haiku. I have more questions now though
First
YOU WON! 🥇🥇🥇
@@ErikDarlingData
Tak!
I think this explains how I've managed to go my whole career without writing an indexed view.
There are times that it's worthwhile. I forget what I said in the video at this point.
I laughed for like 15 mins at the SQL comments for the first 1/3 of the video, then I cried for the last 1/3 of the video because I had no idea how I could take advantage of column store indexes. In the end of this emotional rollercoaster, I thank you.
It’s good that you mostly skipped to acceptance. The other phases are far more painful.
Funny you mentioned web edition last episode. In 2018 I was asked if I was keen to take on a hopeless case with cpu att 100? Sure, sounds like fun! Did it and thats how I found Darling Data. Happy to report its doing great still thanks to your advice :)
Ha ha, well a broken consultant is right twice a day I suppose 😃
Coldfusion! I’ve heard of that. Heard of code written that generates deadlocks. How fun!
Why for the plan with clusterd index scan server doesn't use key(row) locks?
I explain that in the video.
Please explain about Table Hint such as TABLOCK, ROWLOCK thanks!
Well, okay, what questions do you have about them that aren't answered by documentation?
@@ErikDarlingData I don't fully understand. Please help to explain. 😊 thanks
@@RatanaPOUY How can I explain if I don't know what you don't understand?
Been upset with third party vendor code lately that uses a FORCESEEK hint to update a few million records. The web app will lock up for an hour or so and causes all sorts of fun problems for downstream products
If there is a single thing that I'm going to take away from Erik's videos, it's to not fear FORCESEEK.
I wish people used FORCESEEK as much as they used NOLOCK.
Many moons ago at my very first dev job, my first mentor basically wrapped my knuckles with a ruler when she saw me right click a missing index suggestion. It was nice to have someone early on in my career teach me "you cant always trust microsoft" with things like this. Nice content by the way :)
I know i can google this but can you disable index suggestions?
Trace flag 2330 will disable them, but also has other effects.