Earlier quoted context omitted.
That gives you the time cost of a filesystem plus the time cost of a database plus an extra round-trip in and out of kernel space.
> preserving access to the toolchain which operates trivially with files was worth the additional performance overhead of working with the files Sounds like they're OK with that. In any case, couldn't you avoid the kernel trips with some dylib foolery (assuming the toolchain is dynamically linked)?
SQLite small blob storage: 35% Faster Than the Filesystem
171–180 of 208 posts
Re: SQLite small blob storage: 35% Faster Than the Filesystem
#172Earlier quoted context omitted.
I never understood why it mattered that files would be in a single directory or split over multiple directories. At the end of the day it is the same file system with the same number of files. The directories are just a logical structure. Why would there be a difference?
Spinning disks. If you want raw file access, your ideal filesystem is a giant key-value store that keys on the full path to the file. This choice means doing a directory listing will involve a lot of random access reads across the disk, and in the days before SSDs this would be a performance killer. So instead, a directory would have a little section of disk to write its file entries to. These would be fairly small,…
Searching by filename on the other hand can be much faster with a prefix tree because directories only allow linear scans, not range-based ones.
Re: SQLite small blob storage: 35% Faster Than the Filesystem
#173it's not sqlite vs filesystem it's memory storage vs disk storage
Re: SQLite small blob storage: 35% Faster Than the Filesystem
#174I must point out Jim Gray's paper To Blob or Not To Blob[0]. His team considered NTFS vs. SQL Server, but most rationale applies to any filesystem vs. database decision. The summary was "The study indicates that if objects are larger than one megabyte on average, NTFS has a clear advantage over SQL Server. If the objects are under 256 kilobytes, the database has a clear advantage. Inside this range, it depends on how…
My experience (for an application which had a working set of under 1 GB of files in the 50kb to N MB range, and approximately 50 GB persisted at any given time) was that preserving access to the toolchain which operates trivially with files was worth the additional performance overhead of working with the files and, separately, occasionally having to retool things to e.g. not have 10e7 files in a single folder, which…
Re: SQLite small blob storage: 35% Faster Than the Filesystem
#175Earlier quoted context omitted.
Ah, but the filesystem has to do all that as well! It must receive a path, parse it, and then execute the query, with possible optimizations (eg. ext4 even has indexes implemented with hashed b-trees). A filesystem is just an hierarchical database.
>A filesystem is just an hierarchical database. Loosely. Today's file systems aren't transactional (i.e. acid compliance), which is a basic property that most people consider necessary for a database.
Re: SQLite small blob storage: 35% Faster Than the Filesystem
#176Earlier quoted context omitted.
I figured there was something massively annoying with it. I'm hoping that PostgreSQL can try to tackle this use-case somehow because it's so damn common and 99% of the time the solution that is used completely throws out all the guarantees that the database gives you.
I'm not sure there's a non-annoying way to bridge the problem. The semantics are just so different that there's a lot of friction that needs to be handled somewhere. (What does O_DIRECT mean in this context? What happens when someone decides to store files that are never normally closed?) In some ways, the problem mirrors OR mappers. A lot of common cases can be handled, but there are always situations where you're c…
Re: SQLite small blob storage: 35% Faster Than the Filesystem
#177Earlier quoted context omitted.
> e.g. not have 10e7 files in a single folder, which is something that Linux has some opinions (none of them good) about. I keep running in to this as a common anti-pattern in software, even with software developers that should know better (having fallen afoul of it before). I ran in to it with some semi-bespoke software once, used by a remarkable number of state departments across the country. It was one of many, ma…
I never understood why it mattered that files would be in a single directory or split over multiple directories. At the end of the day it is the same file system with the same number of files. The directories are just a logical structure. Why would there be a difference?
Re: SQLite small blob storage: 35% Faster Than the Filesystem
#178Earlier quoted context omitted.
Data chunks inside another file are effectively quarantined by default. There is no exempting or security issue, it's safe by design. It will get scanned occasionally but not on every write.
Except when they are not. Just because malcode is encapsulated doesn't mean it is neutralised. The issue is untrusted data, not how it is stored. Word Docs with embedded content or can trigger code execution on parsing, data structures that break AV parsers, image or font data that causes system libraries to overflow/UAF/etc; There all could potentially be a security issue in a DB, the same as in a FS.
Re: SQLite small blob storage: 35% Faster Than the Filesystem
#179SQLite is good when you’re mostly reading. For writing, the major drawback of SQLite is it doesn’t support concurrent writes. All filesystems do (at least when writing different files), all full-fledged RDBMS-es do, even some embedded databases do (like ESENT). Yet, in SQLite only a single thread can write. Even embedded chips are multicore these days…
Isn't that because SQLLite's whole use case is "simple, small, fast database that competes with fopen() and not Postgres"? At least in my experience on NTFS, unless you know the section that 2 threads are writing to, and that section is different, you can't write to a file concurrently (N.B.: in C#) I'd be happy to be wrong (seriously that would make my day if someone could explain a clean way to do the above) but if…
The hardware evolved in a way so even very small systems (phones, embedded, Raspberry Pi and other IoT devices) are now multi core. Multithreading is required to benefit from a multi-core CPU. For IO-heavy tasks, it’s sometimes a good idea to implement multi-threaded IO as well.
> you can't write to a file concurrently
I can concurrently write different files. Or to different streams/blobs/records for most other IO methods, except SQLite.
Re: SQLite small blob storage: 35% Faster Than the Filesystem
#180it's basically storing in memory vs storing on a disk it's not sqlite vs filesystem it's memory storage vs disk storage