8 ms·
> In the end, I always come back to Postgres. It's unbelievably powerful, lightweight and there's not much it can't do. Well, depends on how wide your definiti
by eru 6y ago
> In the end, I always come back to Postgres. It's unbelievably powerful, lightweight and there's not much it can't do.
Well, depends on how wide your definition is:
Filesystems are also databases. (And eg inside of Google, they are using databases to store filesystems.)
These days, we often think of relational databases. Filesystems are more like the hierarchical databases of yore that Codd (also) talked about in his original papers.
- encryptluks2 6y agoWould love to be able to have a database file system and be able to use standard Linux tools to query and make changes, back up, etc. For example, having a folder of contacts with each file named after the person and having key/value pairs. Similar to how static site generators use YAML/TOML/JSON.
- nix23 6y agoThat sounds like ndb: https://9fans.github.io/plan9port/man/man1/ndb.html https://9fans.github.io/plan9port/man/man1/ndb.html https://www.youtube.com/watch?v=e9Y0iDXXQh8&feature=share https://www.youtube.com/watch?v=e9Y0iDXXQh8&feature=share
- yason 6y agoTry your nearest shell to experiment with this? In my scripts and programs I've stored data just in files many times: simple, transparent and effective. Works everywhere. There's so much in search that you can just brute-force through unless you have a huge amount of data or a lot of concurrent tasks that it doesn't matter much in today's hardware.
- eru 6y agoThe maildir format does something like this.
- busymom0 6y agoThis makes me wonder how efficient filesystems are with millions of file in a single directory? Do they create some sort of index? Are there limits to the number of files a directory can hold? Is that what inodes are for? I remember seeing “inode” limits on some VPS I was using a while back.
- majewsky 6y agoIndeed, putting too many files in a single directory is inefficient, both for read and write. When writing a file (or changing metadata like permissions), the entire directory inode may have to be rewritten. When searching for a file or opening it, the entire file list for the directory needs to be read (in the worst case where the file is at the end of the list). When you need to store lots of files on disk, it's a common pattern to spread them out in subdirectories. For instance, instead of `files/2d8af74bcb29ad84`, you would have `files/2d/8a/f74bcb29ad84`.
- gugagore 6y agoWhat about on the other end? Why not have each hex digit be a directory along a path? Then you have very, very few files per directory at the cost of deeper hierarchy. What's the practical downside?
- thewakalix 6y ago[epistemic status: amateur speculation] I’d expect it to take up slightly more disk space. More importantly, the more indirections, the longer it’ll take to get to the file.
- pmiller2 6y agoDirectories are just another type of file. So, if you do this, and your filenames are n characters long, you'll end up needing to do n file accesses just to find the file you're looking for. Unless the underlying file system does something to make that particular access pattern fast, well... it's going to be stupidly slow after a certain point.
- pxndxx 6y agoIf you do this, you can add all the files to git and get historical views, changelogs... and if you distribute the "database", you even can know who made what changes!
- encryptluks2 6y agoAlong the lines of what I was thinking. Would be really neat! I already do this to an extent, but with a virtual file system it could automatically sort/categorize/etc like a regular database.
- thinker5555 6y agoThis reminds me a little bit of the filesystem from BeOS (RIP) and Haiku. You cant attach any metadata to any file you want, and it has a system to create queries on that metadata.
- blacktriangle 6y agoVery much miss this. I love how they used this technique to build their email client. Emails were just files on the filesystem with a filesystem plugin that made their metadata queryable. So the email client was just a file browser window with some pre-saved queries that would let you find all emails by date, sender, etc.
- utxaa 6y agoyou can :) even across nfs ... maildir etc ...
- megous 6y agoA job for fuse. :) I'd like having a nice sysfs like view on all tables and other objects in a database. Even better if editable. Or alternatively a midnight commander for databases. :)
- encryptluks2 6y agoOMG yes. Now this would be perfect for SQLite.
- bentcorner 6y agoWinFS was an attempt at this. It'd be interesting to learn why it was cancelled. https://en.wikipedia.org/wiki/WinFS https://en.wikipedia.org/wiki/WinFS
- tinus_hn 6y agoBecause it tries to make people work in a way they don’t want to work. People want to organize their files in folders. They don’t want to tag them all with labels or tags and they don’t want to input all that metadata. Perhaps they want to tag a few, and it’s useful to have some autodetected metadata but they don’t want to tag them all and they don’t want a gigantic ‘Untagged files’ list. They want folders and they want more than a flat folder list, they want nested folders. You can implement it, it’s not hard and most modern file systems have all the features you need. But users will hate it and won’t use it the way you want.
- eru 6y agoYou are right that users don't want to do that busy work. But I am less sure users actually want folders. Some power-users, sure. But most normal people don't want to deal with folders, either. For evidence: look at the guy who saves everything on his overflowing desktop. Any system that allows people to find their stuff, and perhaps make a few annotations, will be good for them. Google Photos is almost a good example: I don't have to do annotate anything, yet I can search for eg pictures of snow or by location. (I say only 'almost', because while impressive, that system isn't good enough yet to find obscure stuff or to work on contextual cues like 'those pictures I took at home after we came back from shopping sometime in the last few months'.)
- tinus_hn 6y agoThat’s all very nice but a filesystem needs to be able to deal with every type of file on the planet. Which means you can’t automatically detect the contents. And really, a lot of users don’t want an interface that doesn’t allow them to do what they want just because someone else just dumps all their files on the desktop. Apple tried this on iCloud and had to go back. Because, while it makes for nice presentation and usability, there’s a lot of users that it can’t cater for.
- nix23 6y agoI think the difference of a Database and a Filesystem is: In a Filesystem you know where the Data lives, in a Database you know that it lives...but yeah with stuff like Ceph that view gets a little bit foggy.
- eru 6y agoWhat do you mean by `you know where'? For me, all I know is that my filesystem store its data on disk somewhere, I don't really have any clue how that's organised. That's pretty much exactly the same level of knowledge I have about my db. (And yes, I could look into both of them to learn more. And yes, we also have databases and filesystems that get accessed over the network..) File system paths perhaps sound like a location, but there are no more and no less a location than eg tablenames to me. Or URLs.
- bvm 6y ago> inside of Google, they are using databases to store filesystems. I'm struggling to picture this, do you have any links I could read?
- marcyb5st 6y agoGoogler here, I think OP is referring to the relationship between colossus and bigtable [1]. Basically, what happens is that colossus uses bigtable for storing metadata. So, when you issue a command like `ls /some-cluster-directory/myfolder/mysubfolder` you are really querying bigtable instead of a distributed ls on a cluster fs. It is much more complicated than that, but the idea is that using bigtable you create a resemblance of a fs that feels like a fs to use for the most part. [1] http://www.pdsw.org/pdsw-discs17/slides/PDSW-DISCS-Google-Keynote.pdf http://www.pdsw.org/pdsw-discs17/slides/PDSW-DISCS-Google-Ke...
- eru 6y agoYes, that's something like I was going for. (I'm an ex-Googler, but I am glad that my spotty memory gives me ample protection against accidentally giving out company secrets.) I suspect Google Drive is also backed by something that's not a traditional file system, even thought Google Drive tries to look a bit like a file system to the user.
- iudqnolq 6y agoFrom the outside one clue is that you can have two files with the same name, another is the url to a file doesn't change when you move it. Also it's dog slow to list a directory, like 30sec for 50 files.
- hansvm 6y agoYou can experiment with something kind of like this yourself pretty cheaply. Here's an example [0] user-space filesystem that stores its data in an in-memory sqlite file. You could just as easily replace those in-memory calls with a networked DB (perhaps with speculative pre-fetching or something, I dunno, I probably wouldn't try to make a python filesystem too performant). The salient detail here is that as far as your kernel is concerned a filesystem is an API for interacting with data (whether that's with a daemon process like the linked example or with raw function calls built into the kernel). Those APIs can and often do interact with structures physically stored on a local disk, but that isn't a requirement. [0] http://www.rath.org/pyfuse3-docs/example.html#in-memory-file-system http://www.rath.org/pyfuse3-docs/example.html#in-memory-file...
- exyi 6y agoFilesystem is like a database. Except for transactions, which is very important when multiple processes can access it.
- rurban 6y agoBut filesystems are secure (mostly, ignoring unicode issues) whilst sqlite is an insecure hack. You'll have hard time to harden sqlite, removing all the insecure defaults, fix the broken and exploitable full text search apis, but esp. its built-in hacks. Like explained here https://github.com/rurban/hardsqlite https://github.com/rurban/hardsqlite or here https://research.checkpoint.com/2019/select-code_execution-from-using-sqlite/ https://research.checkpoint.com/2019/select-code_execution-f...