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

      Report: 71% of tech leaders won’t hire devs without AI skills

      July 17, 2025

      Slack’s AI search now works across an organization’s entire knowledge base

      July 17, 2025

      In-House vs Outsourcing for React.js Development: Understand What Is Best for Your Enterprise

      July 17, 2025

      Tiny Screens, Big Impact: The Forgotten Art Of Developing Web Apps For Feature Phones

      July 16, 2025

      Pokémon has partnered with one of the biggest PC gaming brands again, and you can actually buy these accessories — but do you even want to?

      July 17, 2025

      AMD’s budget Ryzen AI 5 330 processor will introduce a wave of ultra-affordable Copilot+ PCs with its mobile 50 TOPS NPU

      July 17, 2025

      Steam takes down tons of porn games, cracks down on “certain kinds of adult-only content” — here’s why, and its new policy

      July 17, 2025

      Oblivion Remastered and Metal Gear Solid Delta co-developer Virtuos faces layoffs — with 270 workers cut

      July 17, 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

      The details of TC39’s last meeting

      July 17, 2025
      Recent

      The details of TC39’s last meeting

      July 17, 2025

      Notes Android App Using SQLite

      July 17, 2025

      How to Get Security Patches for Legacy Unsupported Node.js Versions

      July 17, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Pokémon has partnered with one of the biggest PC gaming brands again, and you can actually buy these accessories — but do you even want to?

      July 17, 2025
      Recent

      Pokémon has partnered with one of the biggest PC gaming brands again, and you can actually buy these accessories — but do you even want to?

      July 17, 2025

      AMD’s budget Ryzen AI 5 330 processor will introduce a wave of ultra-affordable Copilot+ PCs with its mobile 50 TOPS NPU

      July 17, 2025

      Steam takes down tons of porn games, cracks down on “certain kinds of adult-only content” — here’s why, and its new policy

      July 17, 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

    Pokémon has partnered with one of the biggest PC gaming brands again, and you can actually buy these accessories — but do you even want to?

    July 17, 2025
    News & Updates

    AMD’s budget Ryzen AI 5 330 processor will introduce a wave of ultra-affordable Copilot+ PCs with its mobile 50 TOPS NPU

    July 17, 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

    Distribution Release: Ubuntu 25.04

    News & Updates

    How To Enable Google AI Mode in India

    Web Development

    Windows 11 KB5060829 issues affect some, but still a good update for games

    Operating Systems

    Why I bought a $5,300 Apple Mac Studio in the midst of tariffs news – and don’t regret it

    News & Updates

    Highlights

    CVE-2025-4889 – Code-projects Tourism Management System Buffer Overflow Vulnerability in User Registration Component

    May 18, 2025

    CVE ID : CVE-2025-4889

    Published : May 18, 2025, 6:15 p.m. | 6 hours, 9 minutes ago

    Description : A vulnerability has been found in code-projects Tourism Management System 1.0 and classified as critical. This vulnerability affects the function AddUser of the component User Registration. The manipulation of the argument username/password leads to buffer overflow. Local access is required to approach this attack. The exploit has been disclosed to the public and may be used.

    Severity: 5.3 | MEDIUM

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    Load Balancing with Azure Application Gateway and Azure Load Balancer – When to Use Each One

    May 14, 2025

    TacticAI: an AI assistant for football tactics

    May 13, 2025

    Microsoft tests Windows 11 24H2 update with new image editing, Start menu changes

    April 11, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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