Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      10 Top Generative AI Development Companies for Enterprise Node.js Projects

      August 30, 2025

      Prompting Is A Design Act: How To Brief, Guide And Iterate With AI

      August 29, 2025

      Best React.js Development Services in 2025: Features, Benefits & What to Look For

      August 29, 2025

      August 2025: AI updates from the past month

      August 29, 2025

      This 3-in-1 charger has a retractable superpower that’s a must for travel

      August 31, 2025

      How a legacy hardware company reinvented itself in the AI age

      August 31, 2025

      The 13+ best Walmart Labor Day deals 2025: Sales on Apple, Samsung, LG, and more

      August 31, 2025

      You can save up to $700 on my favorite Bluetti power stations for Labor Day

      August 31, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Call for Speakers – JS Conf Armenia 2025

      August 30, 2025
      Recent

      Call for Speakers – JS Conf Armenia 2025

      August 30, 2025

      Streamlining Application Automation with Laravel’s Task Scheduler

      August 30, 2025

      A Fluent Path Builder for PHP and Laravel

      August 30, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Windows 11 KB5064081 24H2 adds taskbar clock, direct download links for .msu offline installer

      August 30, 2025
      Recent

      Windows 11 KB5064081 24H2 adds taskbar clock, direct download links for .msu offline installer

      August 30, 2025

      My Family Cinema not Working? 12 Quick Fixes

      August 30, 2025

      Super-linter – collection of linters and code analyzers

      August 30, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: Just a Few Updates

    CodeSOD: Just a Few Updates

    July 17, 2025

    Misha has a co-worker who has unusual ideas about how database performance works. This co-worker, Ted, has a vague understanding that a SQL query optimizer will attempt to find the best execution path for a given query. Unfortunately, Ted has just enough knowledge to be dangerous; he believes that the job of a developer is to write SQL queries that will “trick” the optimizer into doing an even better job, somehow.

    This means that Ted loves subqueries.

    For example, let’s say you had a table called tbl_updater, which is used to store pending changes for a batch operation that will later get applied. Each change in updater has a unique change key that identifies it. For reasons best not looked into too deeply, at some point in the lifecycle of a record in this table, the application needs to null out several key fields based on the change value.

    If you or I were writing this, we might do something like this:

    update tbl_updater set id = null, date = null, location = null, type = null, type_id = null
    where change = @change
    

    And this is how you know that you and I are fools, because we didn’t use a single subquery.

    update tbl_updater set id = null where updater in
            (select updater from tbl_updater where change = @change)
    
    update tbl_updater set date = null where updater in
            (select updater from tbl_updater where change = @change)
    
    update tbl_updater set location = null where updater in
            (select updater from tbl_updater where change = @change)
           
    update tbl_updater set type = null where updater in
            (select updater from tbl_updater where change = @change)
           
    update tbl_updater set date = null where updater in
            (select updater from tbl_updater where change = @change)
           
    update tbl_updater set type_id = null where updater in
            (select updater from tbl_updater where change = @change)
    

    So here, Ted uses where updater in (subquery) which is certainly annoying and awkward, given that we know that change is a unique key. Maybe Ted didn’t know that? Of course, one of the great powers of relational databases is that they offer data dictionaries so you can review the structure of tables before writing queries, so it’s very easy to find out that the key is unique.

    But that simple ignorance doesn’t explain why Ted broke it out into multiple updates. If insanity is doing the same thing again and again expecting different results, what does it mean when you actually do get different results but also could have just done all this once?

    Misha asked Ted why he took this approach. “It’s faster,” he replied. When Misha showed benchmarks that proved it emphatically wasn’t faster, he just shook his head. “It’s still faster this way.”

    Faster than what? Misha wondered.

    [Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleWhatSie – WhatsApp web client
    Next Article Plasma Bigscreen: L’interfaccia TV basata su KDE ritorna con nuove funzionalità

    Related Posts

    News & Updates

    This 3-in-1 charger has a retractable superpower that’s a must for travel

    August 31, 2025
    News & Updates

    How a legacy hardware company reinvented itself in the AI age

    August 31, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Disposable Email Detection in Laravel

    Development

    A Step-by-Step Tutorial on Connecting Claude Desktop to Real-Time Web Search and Content Extraction via Tavily AI and Smithery using Model Context Protocol (MCP)

    Machine Learning

    Unlocking Inner Riches: How Artificial Intelligence is Revolutionizing Meditation for Wealth Creation?

    Artificial Intelligence

    Perficient Earns AWS Premier Tier Services Partner Status and Elevates AI Innovation in the Cloud

    Development

    Highlights

    News & Updates

    This tiny SSD can have up to 8TB of storage, and I could fit a dozen of them in my pockets

    June 11, 2025

    The Crucial X10 Portable SSD is one of the smallest I’ve used, but boasts absurd…

    From Static to Dynamic: 3 Micro-Animations Every Web Developer Can Master with Rive

    July 1, 2025

    Rilasciata T2 Linux SDE 25.4: la distribuzione versatile con supporto AMD ROCm per RISC-V e ARM64

    April 15, 2025

    CVE-2025-5617 – PHPGurukul Online Fire Reporting System SQL Injection Vulnerability

    June 4, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.