2 ms·
> But it can often be tolerably handled with a row-level flag in the outer-database to handle "locking" the database if you are operating in a scanrio where tha
by fusiongyro 14y ago
> But it can often be tolerably handled with a row-level flag in the outer-database to handle "locking" the database if you are operating in a scanrio where that makes sense.
You do that and you're just trading one race condition for another.
> There are other scenarios where users simply aren't writing anything to the inner SQLite databases, but you are simply using it as a storage medium.
It's a pretty labor-intensive method. Many databases have other ways of introducing unstructured data that aren't going to murder performance. PostgreSQL's hstore, for example.
> the user might check out a model to work on in isolation of the parent system, the data might be stored as SQLite databases instead of some proprietary bit bucket, and then uploaded back to the server in total where the model data is yanked out for server side processing
I have a friend who has used SQLite as an interchange format. It worked reasonably well, but he also didn't have to worry much about schema versions. Still, you can do that without making your backend pay the penalty.
> The above scenario, where isolating the user's datapool so that they can take it offline, do work, then check it back in to the system is almost absurdly simple.
It's still more work than using a file system for no advantage. Just having it in the database doesn't necessarily constitute a win—most DBAs would suggest you weigh the filesystem alternative against dumping files into BLOBs in the database before deciding which way to go.
There will always be exceptions to any hard and fast rule, but I don't think the ones you've described above warrant this design.
- lloeki 14y ago> You do that and you're just trading one race condition for another. SELECT pk, sqlite, version FROM foo; -- later UPDATE foo SET sqlite='myblob', version=43 WHERE pk = whatever and version = 42; -- if zero row update, there's a conflict Those are not the race conditions you are looking for. Terrible design though. Purely a thought experiment but I'm wondering if a Postgres SQLite data type (similar to the JSON data type) could be workable.
- fusiongyro 14y agoIt's true. Hibernate even has special support for this ("row versioning") which I should have remembered. This isn't a race condition, but it is foisting more work on the developer that the database is already prepared to do (albeit in a different manner). The advantage to having a SQLite datatype would be that you could do the kinds of things you can do with the XML data type (extracting information in the outer layer for querying, indexing or simply ensuring validity) but you're still going to thrash the disk with every little change. And once you've committed to Postgres, you may as well use its own solution to this problem, schemas.