5 ms·
This feels like a very elaborate way of saying that doing O(N) work is not a problem, but doing O(N) network calls is.
by rustybolt 8mo ago
This feels like a very elaborate way of saying that doing O(N) work is not a problem, but doing O(N) network calls is.
- jstummbillig 8mo agoIt being so obvious, why is sqlite not the de facto standard?
- skrebbel 8mo agoI haven't investigated this so I might be behind the times, but last I checked remotely managing an SQLite database, or having some sort of dashboarding tool run management reporting queries and the likes, or make a Retool app for it, was very messy. The benefit of not being networked becomes a downside. Maybe this has been solved though? Anybody here running a serious backend-heavy app with SQLite in production and can share? How do you remotely edit data, do analytics queries etc on production data?
- Sammi 8mo agoMy best answer so far is ssh and sqlite3 cli.
- chuckadams 8mo agoNo network, no write concurrency, no types to speak of... Where those things aren't needed, sqlite is the de facto standard. It's everywhere.
- mickeyp 8mo agoPerfect summary. I'll add: insane defaults that'll catch you unaware if you're not careful! Like foreign keys being opt-in; sure, it'll create 'em, but it won't enforce them by default!
- ogogmad 8mo agoIs it possible to fix some of these limitations by building DBMSes on top of SQLite, which might fix the sloppiness around types and foreign keys?
- Polizeiposaune 8mo agoUsing the API with discipline goes a long way. Always send "pragma foreign_keys=on" first thing after opening the db. Some of the types sloppiness can be worked around by declaring tables to be STRICT. You can also add CHECK constraints that a column value is consistent with the underlying representation of the type -- for instance, if you're storing ip addresses in a column of type BLOB, you can add a CHECK that the blob is either 4 or 16 bytes.
- BenjiWiebe 8mo agoSQLite did add 'STRICT' tables for type enforcement. Still doesn't have a huge variety of types though.
- mikeocool 8mo agoThe fact that they didn’t make STRICT default is really a shame. I understand maintaining backwards compatibility, but the non-strict behavior is just so insane I have a hard time imagine it doesn’t bite most developers who use SQLite at some point.
- sethops1 8mo agoNearly every default setting in sqlite is "wrong" from the outset, for typical use cases. I'm surprised packages that offer a sane configuration out of the box aren't more popular.
- sgbeal 8mo ago> The fact that they didn’t make STRICT default is really a shame. SQLite makes strong backwards-compatibility guarantees. How many apps would be broken if an Android update suddenly defaulted its internal copy of SQLite to STRICT? Or if it decided to turn on foreign keys by default? Those are rhetorical questions. Any non-0 percentage of affected applications adds up to a big number for software with SQLite's footprint. Software pulling the proverbial rug out from under downstream developers by making incompatible changes is one of the unfortunate evils of software development, but the SQLite project makes every effort to ensure that SQLite doesn't do any rug-tugging.
- andersmurphy 8mo agoI mean it has blob types. Which basically means you can implement any type you want. You can also trivially implement custom application functions to work on these blob types in your queries. [1] - [1] https://sqlite.org/appfunc.html https://sqlite.org/appfunc.html
- Cthulhu_ 8mo agoIt is for use cases like local application storage, but it doesn't do well in (or isn't designed for) concurrent use cases like any networked services. SQLite is not like the other databases.
- dahart 8mo agoPartly for the same reason it’s fast for small sites. In their words: “SQLite is not client/server”
- jerf 8mo agoIsn't SQLite a de facto standard? Seems like it to me. If I want an embedded SQL engine, it is the "nobody got fired for selecting" choice. A competitor needs to offer something very compelling to unseat it.
- jstummbillig 8mo agoI mean as in: Most web stacks do not default to sqlite over MySQL or postgres. Why not? Best default for most users, apparently.
- conradkay 8mo agoI think in the past it was more obvious. Rails switched to SQLite as the default somewhat recently
- jstummbillig 8mo agoYeah, that's the one prominent example but, like you said, also just rather recently. Since "the network is slow, duh" has always been true, I wonder why.
- Kerrick 8mo agoIt took a lot: https://fractaledmind.com/2023/12/23/rubyconftw/ https://fractaledmind.com/2023/12/23/rubyconftw/ and https://news.ycombinator.com/item?id=39835496 https://news.ycombinator.com/item?id=39835496
- conradkay 8mo agoMy guess would be that performance improvements (mostly hardware from Moore's law and the proliferation of SSDs, but also SQLite itself) have led to far fewer websites needing to run on more than 1 computer, and most are fine on a $5/month VPS And stuff like https://litestream.io/ https://litestream.io/ or SQLite adding STRICT mode
- Kerrick 8mo agoIt's becoming so! Rails devs are starting to ship SQLite to production. It's not just for their main database either... it's replacing Redis for them, too.
- password4321 8mo agoAs another example, a SQL Server optimization per https://learn.microsoft.com/en-us/sql/t-sql/statements/set-nocount-transact-sql#remarks https://learn.microsoft.com/en-us/sql/t-sql/statements/set-n...: > For stored procedures that contain several statements that don't return much actual data, or for procedures that contain Transact-SQL loops, setting SET NOCOUNT to ON can provide a significant performance boost, because network traffic is greatly reduced.
- Neywiny 8mo agoRather I think their point is that since O(N) is really X * N, it's not the N that gets you, it's the X.
- ahartmetz 8mo ago...and the difference between "a fancy hash table" (in-process SQLite) and doing a network roundtrip is a few orders of magnitude.
- direwolf20 8mo agoRight — the network database is also doing O(N) work to return O(N) results from one query but the multiplier is much lower because it doesn't include a network RTT.
- zffr 8mo agoIMO the page is concise and well written. I wouldn’t call it very elaborate. Maybe the page could have been shorter, but not my much.
- sodapopcan 8mo agoIt's inline with what I perceive as the more informal tone of the sqlite documentation in general. It's slightly wordier but fun to read, and feels like the people who wrote it had a good time doing so.