TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

SQLite and the N+1 (No) Problem

9 点作者 philippta超过 2 年前

1 comment

metadat超过 2 年前
Yes, this covers one of the major pitfall disadvantages to using ORMs- the complex realities are hidden away behind ergonomic, easy to use abstractions. ORMs make it easy and intuitive to blunder along without actually fully understanding the actual macro effects of what you&#x27;ve created, and it is easy to end up with a resulting system where the query volume grows super-linearly with the size of the dataset. This then leads to nasty performance problems, but only later on when the system has grown up!<p>So as more data gets into the system, eventually the performance suddenly &#x2F; abruptly degrades and falls off a cliff, and can be very expensive and challenging to address at the more advanced stage (data migrations in general are the bane of many a developer, with the above situation being one of the nastiest problem classes to deal with).<p>As a case study, consider Twitter in it&#x27;s earlier days (a decade ago, circa 2010) - back when they were on Ruby-on-Rails and growing and scaling up like crazy.<p>There were outages just about every Friday. Not saying it&#x27;s all due to RoR, but this was certainly a contributing factor, as the complexity was then forced to move to even more problematic areas (such as singular mega servers for large accounts like Bieber and Obama, which then introduced SPoFs).<p>As for the conclusion in this piece, that SQLite isn&#x27;t susceptible to this issue, cool observation :).<p>No network == no network latency, only local disk latency. I think it could still be problematic if the underlying dataset grows large, but the Presenter is offering a valid strategy to kick the can down the road quite a ways<p>In the end it boils down to CAP theorem trade-offs. If the DB is local FS only, both availability and partition tolerance are both sacrificed.<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;CAP_theorem" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;CAP_theorem</a><p>p.s. Thank you @philippta for sharing this thought provoking piece, I&#x27;m grateful you laid the groundwork for the opportunity for me to write and share what I hope is useful information to other folks! Cheers.