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

      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

      Kong AI Gateway 3.11 introduces new method for reducing token costs

      July 16, 2025

      Got ChatGPT Plus? You can record and summarize meetings on a Mac now – here’s how

      July 17, 2025

      I put this buzzworthy 2-in-1 robot vacuum to work in my house – here’s how it fared

      July 17, 2025

      AI agents will change work and society in internet-sized ways, says AWS VP

      July 17, 2025

      This slick gadget is like a Swiss Army Knife for my keys (and fully trackable)

      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

      Microsoft says it won’t change Windows 11’s system tray design after users feedback

      July 17, 2025
      Recent

      Microsoft says it won’t change Windows 11’s system tray design after users feedback

      July 17, 2025

      How Rust’s Debut in the Linux Kernel is Shoring Up System Stability

      July 17, 2025

      Microsoft is on track to become the second $4 trillion company by market cap, following NVIDIA — and mass layoffs

      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

    Got ChatGPT Plus? You can record and summarize meetings on a Mac now – here’s how

    July 17, 2025
    News & Updates

    I put this buzzworthy 2-in-1 robot vacuum to work in my house – here’s how it fared

    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

    Rilasciato ONLYOFFICE Docs 9.0: più smart, più formati, più potente

    Linux

    CVE-2025-49113: Roundcube RCE Exploit Unveiled—The Swiss Army Knife of Webmail Just Got a Weaponized Blade

    Security

    Why Synology’s new NAS drive support policy isn’t as bad as I first thought

    News & Updates

    Denmark Follows Germany in Ditching Microsoft for Open-Source Tools

    Operating Systems

    Highlights

    CVE-2025-4819 – Y_Project RuoYi Remote Improper Authorization Vulnerability

    May 17, 2025

    CVE ID : CVE-2025-4819

    Published : May 17, 2025, 6:15 a.m. | 2 hours, 52 minutes ago

    Description : A vulnerability classified as problematic has been found in y_project RuoYi 4.8.0. Affected is an unknown function of the file /monitor/online/batchForceLogout of the component Offline Logout. The manipulation of the argument ids leads to improper authorization. It is possible to launch the attack remotely. The complexity of an attack is rather high. The exploitability is told to be difficult. The exploit has been disclosed to the public and may be used.

    Severity: 3.1 | LOW

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

    CVE-2025-7087 – “Belkin F9K1122 Web L2TPSetup Stack-Based Buffer Overflow”

    July 7, 2025

    Free Online Fashion AI for virtual try on clothes

    April 2, 2025

    CVE-2025-47112 – Adobe Acrobat Reader Out-of-Bounds Read

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

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