TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

SQLite is 35% Faster Than The Filesystem (2017)

226 pointsby _1cjwalmost 4 years ago

21 comments

jamal-kumaralmost 4 years ago
This gets posted a lot here and I really wonder if anyone&#x27;s bothered to try and replicate these results or test them with different sizes of data on different filesystems - You can see that the greatest disparity is with NTFS&#x2F;windows while linux is pretty close in performance, but they don&#x27;t bother to mention if they&#x27;ve got ubuntu formatted for ext4 or whatever. I can&#x27;t really seem to find anything looking around, and this article is like 5 years old now. I remember showing this very article to a supervisor at one point and he scoffed it off as unnecessary overhead when all I needed was a plain file store and no relational queries at all.<p>It looks like this is the benchmarking code, I&#x27;ll have to go over it for curiosity sometime: <a href="https:&#x2F;&#x2F;www.sqlite.org&#x2F;src&#x2F;file&#x2F;test&#x2F;kvtest.c" rel="nofollow">https:&#x2F;&#x2F;www.sqlite.org&#x2F;src&#x2F;file&#x2F;test&#x2F;kvtest.c</a>
评论 #27899943 未加载
laurent123456almost 4 years ago
Is it a known issue that the filesystem on Windows 10 is so slow? Being 5 times slower than macOS was roughly my experience but I thought there was just something wrong with my Windows laptop. I can&#x27;t find any benchmark or explanation about this.
评论 #27897787 未加载
评论 #27897717 未加载
评论 #27898114 未加载
评论 #27897849 未加载
评论 #27898260 未加载
评论 #27897837 未加载
评论 #27898150 未加载
评论 #27897843 未加载
评论 #27898662 未加载
评论 #27898556 未加载
评论 #27898109 未加载
评论 #27897917 未加载
评论 #27898159 未加载
评论 #27897660 未加载
评论 #27897882 未加载
daenzalmost 4 years ago
Somewhat related, I wrote a fuse-based file system in Rust recently that used SQLite as the backing store for file records, though not the file contents. I imagine I could use it for file content as well, so it&#x27;s good to know more about its performance.<p><a href="https:&#x2F;&#x2F;amoffat.github.io&#x2F;supertag&#x2F;" rel="nofollow">https:&#x2F;&#x2F;amoffat.github.io&#x2F;supertag&#x2F;</a>
评论 #27898632 未加载
评论 #27898279 未加载
评论 #27898064 未加载
评论 #27898459 未加载
xxsalmost 4 years ago
No idea what&#x27;s with the sqlite articles making the front page every other day. This one is pretty old as well.<p><pre><code> The measurements in this article were made during the week of 2017-06-05 using a version of SQLite in between 3.19.2 and 3.20.0.</code></pre>
评论 #27898147 未加载
评论 #27898204 未加载
评论 #27899065 未加载
评论 #27903769 未加载
评论 #27898088 未加载
mpweiheralmost 4 years ago
Hmmm.<p>SQLite is 35% faster reading and writing within a large file than the filesystem is at reading and writing small files.<p>Most filesystems I know are very, very slow at reading and writing small files and much, much faster at reading and writing within large files.<p>For example, for my iOS&#x2F;macOS performance book[1], I measured the difference writing 1GB of data in files of different sizes, ranging from 100 files of 10MB to 100K files of 10K each.<p>Overall, the times span about an order of magnitude, and even the final step, from individual file sizes of 100KB each to 10KB each was a factor of 3-4 different.<p>[1] <a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;gp&#x2F;product&#x2F;0321842847" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;gp&#x2F;product&#x2F;0321842847</a>
mirekrusinalmost 4 years ago
I wondered the other day how things would behave in node if dependencies were in node_modules.sqlite3 (with posibility to eject to edit if needed).
评论 #27897614 未加载
评论 #27897592 未加载
dangalmost 4 years ago
Past related threads:<p><i>35% Faster Than The Filesystem (2017)</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=20729930" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=20729930</a> - Aug 2019 (164 comments)<p><i>SQLite small blob storage: 35% Faster Than the Filesystem</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=14550060" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=14550060</a> - June 2017 (202 comments)
vincent-toupsalmost 4 years ago
I&#x27;d be shocked if this weren&#x27;t the case.
评论 #27898089 未加载
tibbydudezaalmost 4 years ago
Did Microsoft not try embed SQL server as the backing store for files in Windows &quot;Chicago&quot; to make search a fundamental part of the OS ???.
评论 #27898037 未加载
评论 #27898074 未加载
评论 #27898066 未加载
评论 #27898313 未加载
评论 #27898518 未加载
peter_d_shermanalmost 4 years ago
There&#x27;s a great Software Engineering question here, and that is,<p>Should SQLite be modified such that its code, when compiled with a specific #define compilation flag set, be able to act as a <i>drop-in filesystem replacement</i> source code -- for an OS?<p>?<p>I wonder how hard it would be to retool SQLite&#x2F;Linux -- to be able to accomplish that -- and what would be learned (like, what kind of API would exist between Linux&#x2F;other OS and SQLite) -- if that were attempted?<p>Yes, there would be some interesting problems to solve, such as how would SQLite write to its database file -- if there is no filesystem&#x2F;filesystem API underneath it?<p>Also -- one other feature I&#x27;d like -- and that is the ability to do strong logging of up to everything that the filesystem does (if the appropriate compilation switches and&#x2F;or runtime flags are set) -- but somewhere else on the filesystem!<p>So maybe two instances of SQLite running at the same time, one acting as the filesystem and the other acting as the second, logging filesystem -- for that first filesystem...
Seb-Calmost 4 years ago
As much as I love sqlite, if I understand correctly, this is telling that sqlite doing fread on an already opened file is 35% faster than not-sqlite doing fopen+fread on a single file.<p>Is this just a blatantly dishonest comparison, or did I miss something?
whateveracctalmost 4 years ago
Locality strikes again!
评论 #27897576 未加载
Seattle3503almost 4 years ago
SQLite also performs well when there is a large number of &quot;files&quot;. A simulation I wrote used a large number of files (10k+). Eventually I had to transition away from using the file system as a key-value store because open, reads, writes, and directory listings were slow when you have that many files in a single directory and that many open file descriptors.
smoldesualmost 4 years ago
I&#x27;d like to see them bench SQLite against different filesystems, since both fields have progressed quite a bit in the past 4 years.
mjevansalmost 4 years ago
I would love for directories of small files to be stored this way under ZFS; like infrequently updated tar or zip (no compression) files. (Though the filesystem layer of compression might operate on the whole file, or maybe as two streams, one for the file and one for the index.)
评论 #27897751 未加载
评论 #27897686 未加载
71a54xdalmost 4 years ago
It&#x27;s surprising how fast you can get DETS (the persistent storage version of Elixir&#x27;s in memory kv-store ETS) to act as a database of sorts. Even on a relatively slow SSD.
romwellalmost 4 years ago
I wrote an ORM to use SQLite for serializing&#x2F;persisting objects to disk (i.e. using SQLite DB as a file format).<p>This was one of the reasons why SQLite was an easy choice.
bahmbooalmost 4 years ago
Everything is a cache
laurent123456almost 4 years ago
(2017)
xen2xen1almost 4 years ago
So the answer is that NTFS needs a Raid controller with cache RAM? That seems to fix a lot of stuff.
sebyx07almost 4 years ago
then making a small cdn using nginx and sqlite can be a thing?
评论 #27898046 未加载
评论 #27897829 未加载