SShortSingh.
Back to feed

n1scan: a local Postgres proxy that flags N+1 queries in any app or ORM

0
·5 views

N+1 query bugs often escape slow-query logs because each individual query runs quickly, while the loop that issues them slows an endpoint badly. Existing detectors such as Bullet, nplusone, and debug toolbars are tied to specific frameworks and run inside the application process. The author built n1scan, an open-source Go tool that runs as a local proxy between an app and PostgreSQL and reports repeated query shapes with differing values, requiring no code changes. It fingerprints queries, identifies the statement that precedes a burst as the likely parent, and suggests indexes when it detects sequential scans on large tables. The tool is MIT licensed, supports a range of clients and ORMs, and includes a CI mode that returns a failing exit code when an N+1 is detected.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

AiryNight Keeps Nighttime Bedroom Audio On-Device Rather Than Uploading It to the Cloud

The developers of AiryNight, a sleep-tracking app, analyze nighttime audio entirely on the phone instead of sending bedroom recordings to a server. They argue that continuous overnight recordings capture private household sounds that could be exposed by a breach, subpoena, or ownership change even after deletion promises. The app classifies probable snoring with an on-device model and produces a morning summary with a comparative per-hour score, with recordings excluded from backups and deletable at any time. The company acknowledges that purchases are verified through Apple or Google and that optional anonymous usage statistics may be sent, while stating that audio, journal entries, and night results do not leave the device. The app runs on Android 8 or later and iOS 15 or later, with the iOS version about 27.8 MB.

0
ProgrammingDEV Community ·

Java Security Review: Common High-Risk Sinks and Pitfalls in XML, Deserialization and Queries

A security article explains that the most dangerous Java vulnerabilities often hide in ordinary-looking code, where untrusted data flows into sensitive operations called sinks. It notes that default XML parsers in Java enable external entity resolution, exposing applications to file disclosure, server-side request forgery, and denial of service, and that the JDK version alone does not fix this. The author recommends explicitly disabling doctype declarations and external DTD and schema access, configuring these features before the builder is created. The piece also warns that native deserialization with ObjectInputStream and permissive polymorphic typing in Jackson can enable remote code execution, and advises restricting allowed classes with filters or validators. Finally, it highlights a subtle injection risk in dynamic sorting within Spring Data JPA, where unvalidated property names can bypass safeguards.

0
ProgrammingDEV Community ·

Founder Builds Pipeline That Automates Social Media Posting for His SaaS

A founder describes how he stopped manually writing social media posts for his SaaS product by building Bravio, a pipeline that automates the process. The system first reads the company's website to create a brand profile covering products, offers, and tone of voice. Post topics are drawn from real search questions and product features rather than generic tip lists. Content is produced in varied formats such as reels, images, and carousels, adapted automatically to each platform's length and hashtag norms. Finally, posts are scheduled across connected accounts, with comment-keyword DMs driving clicks to the product.

0
ProgrammingDEV Community ·

Unbounded Node.js In-Memory Cache Pushes Memory From 3.4 MB to 200 MB Under Load

A developer ran a Node.js service that cached HTTP responses in a plain Map with no size limit. Load testing with 4,000 requests, each using a unique URL, drove resident memory from 3.4 MB to 200.1 MB with no plateau, since the Map kept every entry reachable. The developer fixed the problem by capping the cache size and evicting the oldest entries, which kept memory flat at 13.6 MB under the same traffic and throughput. The write-up argues that unbounded in-memory caches are a memory leak that often only surfaces in production. It recommends a hard size limit with an eviction policy such as LRU, a TTL for stale data, and load testing with unique keys before shipping.