home.social

#temptable — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #temptable, aggregated by home.social.

  1. Ho appena scoperto che, avendo un SQL Server 2019, posso usare la formula
    DROP TABLE IF EXISTS #tempTable

    al posto del controllo:
    IF OBJECT_ID('tempdb..#tempTable') IS NOT NULL

    Tre righe risparmiate.

    #sql

  2. Ho appena scoperto che, avendo un SQL Server 2019, posso usare la formula
    DROP TABLE IF EXISTS #tempTable

    al posto del controllo:
    IF OBJECT_ID('tempdb..#tempTable') IS NOT NULL

    Tre righe risparmiate.

    #sql

  3. Ho appena scoperto che, avendo un SQL Server 2019, posso usare la formula
    DROP TABLE IF EXISTS #tempTable

    al posto del controllo:
    IF OBJECT_ID('tempdb..#tempTable') IS NOT NULL

    Tre righe risparmiate.

    #sql

  4. (I was reluctant to make the change because I didn't have a high volume non-production environment to do real world testing.

    Plus, I knew the #TempTable sometimes held as many as a thousand rows...even though the guidance for choosing between a #TempTable and a @TableVariable has changed a bit over the last couple of major releases.)

    /fin

  5. Somewhat desperate, I decided to replace the #TempTable with a @TableVariable.

    Boom! Problem solved. 😃

  6. Yet here we were with the same problem once again. This time around, Pam Lahoud's #TempTable guidance was already in place within the stored proc code.

    The server has 128 vCPU and 8 tempdb data files. Maybe I needed to add some more data files?

    Well, I added two more files, but there was no appreciable improvement in performance. Bummer!

  7. I guess it's too late to be brief, but long story short, when we had this problem before, I modified the stored proc to declare the #TempTable in a single statement (including all constraints, indexes, and compression) along with *not* dropping the #TempTable anywhere within the stored proc code.

  8. Still, we had this one query near the top of the shit list: a CREATE #TempTable operation.

    We'd had this once in the past, and I eventually realized it was a very high volume stored procedure causing tempdb metadata contention. Pam Lahoud explains the issue very well in this post: techcommunity.microsoft.com/bl