The great Itzik. I'd forgotten that article, but flip-flopping two tables is a classic solution to this problem. It makes it much mroe complex though. I was hoping to avoid that.
@JohnK.N. Yes. If the goal was to remove the spool then instead of seek and spool I gave scan and sort. You still gotta have Halloween protection, no way around it.
New Focus Styles
We’ve released a design update to focus styles across the many components within our design system and as well as a new design for our button group component.
Why are we updating the focus style?
Prior to these recent changes, we would commonly apply a custom focus ring around el...
I created view based on complex select query (takes 2 second to retrieve the data). When I'm trying to select data from this view based on a predicate, it takes more time (8 second). this is the query plan. what should I do to reduce this long time.
thank you.
execution plan
https://www.brentozar...
@PaulWhite Did you have any bright ideas on that Spool? I was looking over your article but it doesn't fit the MERGE optimizations, not sure what else to try.
I'm looking forward to this classic challenge where people provide solutions to the original challenge, and @Charlieface adds rules each time to make them not valid (e.g., "This is a non-default setup").
Could anyone help me with an English problem? I don't know what to google.
I'm building a program in Python that shows letters in computer and handwritten font so my daughter can practice. I'd like to add top and bottom lines as you'd have them in a workbook.
My main problem is with the letters that go below the line (found out they are called "descenders"). But I don't know how are the top and bottom lines called
@Zikato Tall letters touch both, or are you asking what the top and bottom lines are called? If so I always was told "rule line" but that might be local factors.
@J.D. Because that's the one day you're above 0 coolness? :P
Vlad Țepeș or Vlad the Impaler (1428/31 – 1476/77) was voivode (or prince) of Wallachia three times between 1448 and his death.
Vlad Țepeș may also refer to:
Vlad Tepes (band), a French black metal band
Vlad Țepeș (film), a 1979 Romanian film
Vlad Țepeș, Călărași, a commune
Vlad Țepeș, Giurgiu, a village
Vlad Țepeș League, a political party in interwar Romania
528th Reconnaissance Battalion "Vlad Țepeș", an element of the 2nd Infantry Division of the Romanian Land Forces
== See also ==
Dracula vlad-tepes, a species of Dracula orchid
@Charlieface at first glance, i'd probably dump the child cte into a temp table and truncate it at the end of each loop, using manual phase separation instead, so that the update isn't self-referencing
they're ignored on the table that's getting modified, but if you're relating a table (even the table being modified) in some way elsewhere in the query, you can certainly make incorrect results permanent in the database
@ErikDarling AFAIR they aren't completely ignored, they're still used in the read phase, which then makes deadlocks more likely because missing U-locks.
Thank you for subscribing to Temporal Table facts! Fact #37 - Only tables with Primary Keys on them can be made Temporal. Though you can UPDATE the value of said Primary Key, disconnecting it from its history in the history table anyway.
Also, I don't think Temporal tables respect it correctly as both a DELETE and INSERT in the history table anyway lol.
@Charlieface If I create an AFTER UPDATE trigger on a table, and do an update to that table, isn't the old row version in the virtualized inserted table with the new row version in the virtualized deleted table, reflecting that an UPDATE is really just a DELETE and INSERT under the hood?
If the PK changes it's not the same row anymore, makes no sense to correlate the history.
@J.D. not sure what you mean, it doesn't actually tell you what happened anyway, that's Change Tracking.
@J.D. Don't think so, that's probably just an artifact of the way triggers are set up. For a normal update the page is modified to replace the existing row, if it's a PK change then the whole row is deleted and reinserted.
@Charlieface I guess my point is it seems a little silly of a requirement for Temporal Tables to need a PK if said PK is mutable. But I get it.
@Charlieface Cool, I'll check it out, and will take your word about triggers and what I mentioned being just a design artifact of them. I don't really know, just always assumed. Seems like I'm learning a lot in this 5 minute conversation heh.
@ErikDarling Nah not yet. I don't love it syntactically. I actually found this nugget of knowledge that utilizes some of that syntax and almost had a use case for it.
By the title (and given the example just preceding it) I thought Microsoft was about to tell me how I can manually update the temporal datetime2 columns in the source table. Which is the problem I'm currently stuck on. But was quickly disappointed.
They'll be like "hey here's an example on how to do ABC" and then the example will do "ABC but also not explain XYZ and 123 that had to happen to get to ABC".
"this is obviously much more difficult when using identity or sequence objects, but if your temporal table is used with data pulled from a separate source system, or the application is assigning identity values, you could run into problems..."
From the comments, it appears the real question is not how to UPDATE an ALWAYS GENERATED column, but how to migrate data from a temporal table into a new temporal table. If you need to copy data from a different (temporal) table to a new one, and retain the history dates, then create the new tabl...
@Charlieface Technically true. I might be getting confused in the examples I was just trying to create - to Erik's point about "so much setup" lol. I have to re-test when I'm back in front of a computer but I feel I saw different behavior between updating the PK vs actually deleting the row, than expected.
@Charlieface Just saw you sent this now, thanks! Not sure if it's the same solution as this one but this got me across the finish line. I don't understand it fully yet, seems kinda buggy-ish, but it works.
@SeanGallardy To be fair, it makes little difference which language you use, anything is better than C and C++ (as long as it isn't Perl or PHP!). The amount of footguns that even an expert can give themselves is far beyond modern memory- and type-safe languages. And the libraries and tooling are generally far better in them than in C++.
I'd love to see what SQL Server would look like if it was written in high-perf C#. There's lots of new memory management and Span stuff going in now, and it would be nice to be able to handle tables as real objects. We can but dream.
Fine whatever. Point is I disagree with Sean, moving to a modern language does indeed MAGICALLY fix at least one third of all bugs. I have almost never had an app written purely in a managed language crash and dump on me with an access violation or, and where it did it was a runtime bug, not a bug in my code.
Out of curiosity, do you code anything apart from SQL?
People say SQL isn't a programming language, it is. It just has a specific use-case, and isn't a general-purpose language. Matlab also isn't, for eg.
Arguably C and C++ aren't either, they are high-performance safety-catch-off languages, designed for things like kernels, device drivers and embedded systems.
@Charlieface I have, it's fun, you should try it. Probably why I don't see all this stuff as magical, because while it may have some items that help, there's a trade off. I guarantee changing to the everything is magically safe language of Rust will still result in AVs and other such items, whether or not they are as bad as they are today may be another matter.
Don't blame poor programming on the language (unless it truly is a language issue), blame it on the programmer.
@Charlieface You mean SQL like T-SQL or do you mean SQL like the SQL Server Engine?
How do you get an AV in a managed language? I guess if you redefine Index Out of Range and Null Ref exceptions as AVs then yes, but it's not going to cause undefuned behaviour.
@SeanGallardy But C and C++ really do seem to have more badness than others, so much cruft and backwards-compat etc. And the amount of incomprehensible boiler-plate seems insane sometimes.
It's all very well saying "blame the bad worker" but if you give a diamond cutter a sledgehammer you might not get the right results
I grew up as a kid mucking around with BASIC (hacking x86 machine code into it obviously), moved on to VB, then VB.NET (again some MSIL bytecode), finally got a real job and dumped it all for C# and SQL. But dabbled in Powershell and PHP along the way.
@SeanGallardy Is anyone? Sometimes I think the mark of an actually great coder is Imposter Syndrome. If you don't have it then you probably aren't great.
Yeah I started in BASIC, then VB4, then C, C++, had to do intel and motorola assembly in college, then Java (god I hated Java), switched to PHP for some random projects, then to .net 1/2, asp.net, back to VB6, then C#.
@Charlieface Every time I think I have something down, someone shows me a new way to break it and I feel dumb. I'm not a purist, I don't go around quoting the specs, I'm not in academia where everything is always perfect and works perfect, never any network loss.
For fun I managed to get multi-threading working. The IDE ran the whole code inside the same process, and I crashed it a million times. It was entertaining watching one thread being debugged while the other merrily went on its way. You had to make sure all your extra threads ended before main, otherwise it could garbage collect the code and crash.
Kinda. Like a hundred little publicly owned fiefdoms where some idiots who know nothing about healthcare (or IT clearly) make decisions affecting millions
Everyone been writing WPF for years anyway. And with everything going online it doesn't make much difference. Apple didn't give a toss, they broke everyone twice
@Charlieface oh I mostly meant that the majority of my work is tuning queries. Some of it is writing processes in SQL that are a bit more procedural and requires stuff that looks more like programming.
But the plain answer to your question is that I don’t use anything else