frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Solving the 1+N Query Problem

https://acadia.engineering/blog/solving-the-1-plus-N-query-problem
17•wheatBread•5h ago

Comments

quibono•52m ago
Nice, and I understand why using `getAuthorNames` solves the N+1 here.

But... isn't this solving the problem by removing most of what makes it an issue in the first place? I imagine most people use ORMs for the SQL <-> native class data sync capability. And this assumes one would run the Acadia query instead.

FWIW I'm not trying to be negative, it's just my general impression is that these N+1 usually occur because people _want_ direct object access and _want_ to write loops, and _want_ to access fields and have the underlying SQL be sorted by the ORM.

cnity•26m ago
This is my experience too. The solution is to train people to stop wanting to solve data query problems in the application layer.
lobofta•24m ago
As far as I understand Acadia gives you Acadia <-> Native class data sync, only just Haskell and Elm at the moment unfortunately.

I'd be willing to rewrite queries in some other language that transpiles to SQL if it allows me to do all the queries I want and gives me full compile time type support for db access in return.

The policies look interesting too by the way, but they don't solve a major IMO.

red_admiral•51m ago
This is what you get when you let your ORM loose on the database without understanding JOINs. Especially, the bit where something like 'book.author.name' that looks like a simple field dereference actually is a method call on an ORM proxy object (book), via python's __getattr__ or similar, that fires off a new query if the data you want is not loaded yet.

Some ORMs let you specify the extent of the data that you want, like Hibernate has its own Hibernate Query Language.

At some point you are better off just writing SQL yourself, though. Even without join problems, if you ask an ORM to get the person with user id 123 and all you want is their name, the ORM cannot know that unless to tell it, and so you end up with a 'SELECT *' type query.

cnity•38m ago
ORMs are great. They make the easy queries remain easy and the harder queries impossible.
tehlike•19m ago
This is true but not super true in case of linq and related providers like efcore. Even nhibernate linq would do this.
mrkeen•49m ago
Compare with the prior art of N+1 queries of 2014:

https://github.com/facebook/Haxl/blob/main/example/sql/readm...

jbverschoor•37m ago
Wasn't this 'solved' by Hibernate ages ago?
kstrauser•19m ago
Side note: I strongly prefer referring to this as the "1+N problem" as the author did here. I didn't understand what people were grousing about when they talked about "N+1".

N+1: You're already doing N queries. Is adding 1 more that big of a deal?

1+N: This should have been 1 query, but somehow you blew it up into that one plus N more.

I'd seen that query antipattern plenty of times and knew what it was bad, but didn't realize that's what people meant by "N+1", which I thought must mean something different.

Apple introduces M6 and M5 Ultra for a big leap in performance and AI compute

https://www.apple.com/newsroom/2026/08/apple-introduces-m6-and-m5-ultra-for-a-big-leap-in-perform...
599•interpol_p•4h ago•483 comments

New Mac Studio with M5 Max and M5 Ultra

https://www.apple.com/newsroom/2026/08/apple-introduces-new-mac-studio-with-m5-max-and-m5-ultra/
506•interpol_p•4h ago•315 comments

Nitter project received cease and desist

https://github.com/zedeus/nitter/issues/1442
51•Banditoz•31m ago•10 comments

Bomb fishing is wreaking havoc on Indonesia's coral reefs

https://e360.yale.edu/digest/bomb-fishing-coral-reefs
150•speckx•3h ago•92 comments

Clara (YC P26) Is Hiring a Growth Engineer to Bring AI Doctors to Market

https://www.ycombinator.com/companies/clara-2/jobs/8snci6k-founding-full-stack-growth-engineer
1•gfavvas•10m ago

New Mac mini, featuring M6 and M5 Pro

https://www.apple.com/newsroom/2026/08/apple-unveils-a-more-powerful-mac-mini-featuring-the-all-n...
270•runako•4h ago•140 comments

Black hole singularity is a surface not a point

https://arxiv.org/abs/2608.21590
21•raattgift•36m ago•6 comments

Qwen 3.8-Flash-Next releasing tomorrow (125B a6B)

https://modelscope.cn/models/Qwen/Qwen3.8-Flash-Next
232•garo-pro•5h ago•105 comments

SpaceX – Starbase, LA

https://www.spacex.com/sites/starbase-la
25•bilsbie•1h ago•10 comments

Water Behind the Watts: The Hidden Risk of Powering Data Centers

https://www.ceres.org/resources/reports/water-behind-the-watts-the-hidden-risk-of-powering-data-c...
9•hn_acker•41m ago•3 comments

My Friend Aaron

https://rorz.io/writing/my-friend-aaron
21•sarreph•46m ago•3 comments

Don't Wordle

https://dontwordle.com/
222•Hbruz0•5h ago•90 comments

Building a backyard office, the build and cost breakdown

https://www.imkylelambert.com/articles/building-a-backyard-office-the-build-and-cost-breakdown
124•surprisetalk•3h ago•94 comments

Tooltips Need a Delay, and Then They Need to Skip It

https://blog.master.dev/tooltips-need-a-delay-and-then-they-need-to-skip-it/
13•ibobev•1h ago•2 comments

Warnock: Harnessing GPU Geometry Amplification for Vector Graphics

https://dl.acm.org/doi/pdf/10.1145/3820012
16•coffeeaddict1•2h ago•3 comments

Lightweight system monitor for Linux VPS written in Go

https://github.com/leodeim/vpsmon
3•ygagaga•25m ago•0 comments

Beyond Good and Evil: Nietzsche and the Great War (2019)

https://www.historytoday.com/archive/feature/beyond-good-and-evil-nietzsche-and-great-war
22•samizdis•2h ago•12 comments

HelloAssembly The smallest possible complete Windows application

https://github.com/PlummersSoftwareLLC/HelloAssembly
70•Bluestein•5h ago•37 comments

A new ceiling for Λ: the de Bruijn–Newman constant is at most 0.1787854

https://www.judegomila.com/posts/riemann-lambda-0.1787854
6•judegomila•40m ago•0 comments

iCloud+ Hide My Email addresses will remain on icloud.com

https://developer.apple.com/news/?id=1ptvdtcm
581•K7PJP•19h ago•183 comments

MySQL CDC to BigQuery: what periodic syncs miss, and how binlog avoids it

https://www.erathos.com/en/blog/mysql-cdc-to-bigquery
23•gpaulbagetti•3h ago•8 comments

LatticeDB – Like SQLite but for graph databases

https://github.com/jeffhajewski/latticedb
7•smiths1999•47m ago•2 comments

MS Paint and Photos inivisibly watermark even locally generated output with GUID

https://xusheng.dev/posts/reversing/mspaint_invisible_watermark/main/
826•ComputerGuru•1d ago•411 comments

AI is hitting entry-level jobs hardest, Stanford study finds

https://arstechnica.com/ai/2026/08/ai-is-hitting-entry-level-jobs-hardest-stanford-study-finds/
107•Brajeshwar•2h ago•85 comments

Fuzzing the Gleam Compiler

https://www.kurz.net/posts/fuzzing-gleam-compiler
4•crowdhailer•1h ago•1 comments

Windows 95 released August 24, 1995

https://dfarq.homeip.net/happy-20th-birthday-to-windows-95/
81•giuliomagnifico•10h ago•40 comments

Xiaomi: New CPU matches Apple cores single threaded, much faster multithreaded

https://twitter.com/lemire/status/2091894299289874926
963•tosh•1d ago•700 comments

Visualizing Binary Files

https://movq.de/blog/postings/2026-08-05/0/POSTING-en.html
19•zdw•23h ago•7 comments

Run Minecraft in a Windows Sandbox for Computer Use Agents

https://cua.ai/docs/how-to-guides/sandbox/minecraft
4•someguy101010•1h ago•0 comments

Anthropic tells staff to work from home due to possible security team strike

https://www.businessinsider.com/anthropic-san-francisco-staff-work-remote-office-security-strike-...
78•DGAP•3h ago•86 comments