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.

Show HN: Query SQLite files stored in S3

160 pointsby polyrandover 2 years ago

20 comments

simonwover 2 years ago
This is really neat. It looks like it&#x27;s using a similar trick to <a href="https:&#x2F;&#x2F;phiresky.github.io&#x2F;blog&#x2F;2021&#x2F;hosting-sqlite-databases-on-github-pages&#x2F;" rel="nofollow">https:&#x2F;&#x2F;phiresky.github.io&#x2F;blog&#x2F;2021&#x2F;hosting-sqlite-database...</a> from last year - querying SQLite databases hosted as static files using the HTTP range header to fetch back just the pages from the database file that are needed by a specific query.
评论 #32831849 未加载
评论 #32831725 未加载
psanfordover 2 years ago
I made a similar sqlite vfs in Go[1]. I really love the VFS api. HTTP range queries is about the most mild thing you can do with it. The VFS implementations that use non-traditional backing stores are more fun. Like say, using DynamoDB as a read&#x2F;write backing store for your sqlite database[2].<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;psanford&#x2F;sqlite3vfshttp" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;psanford&#x2F;sqlite3vfshttp</a><p>[2]: <a href="https:&#x2F;&#x2F;github.com&#x2F;psanford&#x2F;donutdb" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;psanford&#x2F;donutdb</a>
评论 #32829766 未加载
评论 #32831230 未加载
Rapzidover 2 years ago
Something really neat about SQLite is how self contained the database file is.. You can take say, a large book or log output, then copy it into a table with full text search. Optimize the DB to get rid of empty space, then ship that out to S3 or something. Now you can fetch that down and have indexed and fts access to the contents.<p>Cool way to store data with indexes into it in a way that makes it as easy to use as copying around and opening a file; no need for dumps or restores or server processes.
评论 #32832899 未加载
评论 #32832348 未加载
ks2048over 2 years ago
This is cool. It would be interesting to see some stats like how many separate requests are needed for a single SELECT statement, since S3 charges per GET, even on a small range, I believe. Obviously that would depend on the query and various DB settings like page_size, etc. Also wondering if this does aggressive local caching for the same reason.
评论 #32830355 未加载
gkaemmerover 2 years ago
This is cool, I&#x27;ll probably end up using this (we store sqlite snapshots in S3).<p>It&#x27;d be very handy if this was packaged as a CLI that worked like `sqlite3`, so you could get a SQL repl by running:<p><pre><code> s3sqlite mybucket&#x2F;mydb.sqlite3</code></pre>
评论 #32831927 未加载
svnpennover 2 years ago
I feel like people are pushing SQLite beyond its limits with this stuff. If you&#x27;re going to do something like this, wouldn&#x27;t just a normal client&#x2F;server option like PostgreSQL be way more performant?<p>I think SQLite is fantastic, but this just smacks of scope creep.
评论 #32830878 未加载
评论 #32830688 未加载
sntranover 2 years ago
This would be quite convenient when dealing with MBtiles files hosted on S3 or similar. There are efforts such as PMTiles[1] that let us use HTTP Range query to retrieve tiles directly from S3, but we still have to convert MBTiles to PMTiles first.<p>More importantly that OSM is considering providing MBTiles directly (besides PBF)[2].<p>[1]: <a href="https:&#x2F;&#x2F;protomaps.com&#x2F;docs&#x2F;pmtiles&#x2F;" rel="nofollow">https:&#x2F;&#x2F;protomaps.com&#x2F;docs&#x2F;pmtiles&#x2F;</a><p>[2]: <a href="https:&#x2F;&#x2F;github.com&#x2F;openstreetmap&#x2F;operations&#x2F;issues&#x2F;565" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;openstreetmap&#x2F;operations&#x2F;issues&#x2F;565</a>
评论 #32834408 未加载
traceroute66over 2 years ago
I admire people for their inventiveness, however surely attempting to square-peg-round-hole something like this into AWS S3 is only going to end up biting them in the backside ?<p>S3 is delivered over a stateless protocol (http) and AWS makes no promises about any given request being fulfilled (the user is merely invited to retry). The safety of your data is then further dependent on what storage tier you chose.<p>There just seem to be so many footgun opportunities here. Why not just use the right tool for the job ? (i.e. hosted DB or compute).
评论 #32834859 未加载
评论 #32834613 未加载
civilizedover 2 years ago
This is nice, but before you go to the trouble of using it, consider just putting your CSV, JSON, or parquet data file in S3 and query it with S3 Select <a href="https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;AmazonS3&#x2F;latest&#x2F;userguide&#x2F;selecting-content-from-objects.html" rel="nofollow">https:&#x2F;&#x2F;docs.aws.amazon.com&#x2F;AmazonS3&#x2F;latest&#x2F;userguide&#x2F;select...</a><p>I haven&#x27;t tried this myself but parquet + S3 select should be especially good for analytical queries.
评论 #32832328 未加载
wanghqover 2 years ago
If I need to query the db repeatedly (N times per second), isn&#x27;t it more efficient (low latency and aws cost) to just download the db and run queries locally?
rgovostesover 2 years ago
I was thinking it would be nice if there were a generic VFS library for C that offered stdio-like APIs (fread, fprintf, etc.) in order to do tricks like this beyond SQLite, without having to make major changes porting existing codebases over to different APIs.<p>It occurs to me that because a FILE * is an opaque pointer, it ought to be possible for a libc to provide this functionality: the FILE struct could contain function pointers to the the underlying implementations for writing, flushing, etc.<p>This ought to be backwards compatible with existing FILE * returning APIs (fopen, fdopen, popen), while allowing new backing stores without having to rewrite (or even recompile) existing code.
评论 #32831531 未加载
评论 #32831535 未加载
JaggerFooover 2 years ago
I read of someone using AWS EFS for sqlite, which has nfs functionality, if I recall correctly.<p>However I like the idea of using a local store with litestream to S3 and updating to the latest db data from S3, if using my application on another device or computer. Sort of like github.<p>Tailscale was looking into this option, instead of Postgres and other DBs. <a href="https:&#x2F;&#x2F;tailscale.com&#x2F;blog&#x2F;database-for-2022&#x2F;" rel="nofollow">https:&#x2F;&#x2F;tailscale.com&#x2F;blog&#x2F;database-for-2022&#x2F;</a><p>Cheers
banana_giraffeover 2 years ago
I implement a similar concept for Python using APSW and boto3.<p><a href="https:&#x2F;&#x2F;gist.github.com&#x2F;Q726kbXuN&#x2F;56a095d0828c69625fa44c23118e5221" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;Q726kbXuN&#x2F;56a095d0828c69625fa44c2311...</a><p>It&#x27;s not really useful for deep dives into data, though it has gotten me out of a few jams that would have otherwise required a real database just to pull out a value or two from a large dataset.
aleph-over 2 years ago
Nifty, reminds me of <a href="https:&#x2F;&#x2F;github.com&#x2F;backtrace-labs&#x2F;verneuil" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;backtrace-labs&#x2F;verneuil</a> or possibly <a href="https:&#x2F;&#x2F;litestream.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;litestream.io&#x2F;</a>
endisneighover 2 years ago
There have been many of these custom vfs implementations. Is there a benchmark on performance between them?
staticassertionover 2 years ago
A comparison to S3 Select would make sense since S3 Select lets you leverage RANGE, leverage compact formats like compressed Parquet, and would presumably have a similar fundamental cost ie: get + data transfer.
Datageneratorover 2 years ago
This could be done by mounting S3 as filesystem and plain sqlite. Any differences?
评论 #32830018 未加载
评论 #32830708 未加载
redleader55over 2 years ago
Sorry for the stupid question: does this work with MinIO?
评论 #32831581 未加载
lootsauceover 2 years ago
Has anyone created a vfs for redis?
remramover 2 years ago
Is there a benefit over the existing S3 VFS sqlite3-s3vfs,which also uses APSW?
评论 #32829729 未加载
评论 #32829692 未加载