amol- / depot

Toolkit for storing files and attachments in web applications
MIT License
161 stars 41 forks source link

Does Depot allow for storing relational data in Redis? #49

Closed rlam3 closed 5 years ago

rlam3 commented 6 years ago

Does Depot allow for storing data in Redis instead but still be able to use SQLAlchemy models to retrieve the data?

Meaning... How do I use SQLAlchemy Model to retrieve the data of the image uploaded to S3. But have the data on Redis?

I'm asking because I'm under the impression that it is costly in the long run to store a read-only data structure in a postgres environment. It can be done, but is it necessary?

Thanks!

vlcinsky commented 6 years ago

@rlam3 in short, I think it is not possible.

In detail:

There different kinds of storages:

So to your questions:

You are right, that storing (larger amounts) of read-only data blobs in relational database is often not very efficient. This is exactly where depot shines. And if you really need to do searches based on blob content, you wold have to deploy some sort of indexing (it would be very close to full text search solution).

My conclusions: Do not expect simple queries based on attributes hidden inside depot managed blobs.

Redis as middleware would be very similar to existing in-memory model with advantages such as persistence and scaling.

rlam3 commented 6 years ago

@vlcinsky Thank you for your input. I believe there was some misunderstanding in my comment above. What I would like to re-emphasize is the use of storing read-only data in Postgres doesn't make sense. Efficiency wise...

I'd like to know if there was a better way to store the .file/ metadata for the path of the url/sizes/etc... instead through a large blob inside postgres table/cell. This is where I was thinking of using Redis or some NOSQL to store this data and have a reference back to SQLALCHEMY model.

The file currently goes straight to S3. This is not what I'm worried about.

Thanks.

amol- commented 6 years ago

I'm not sure I got the benefit that you hope to achieve by storing value of the file metadata if you had to load the model pointing to those files anyway {as you are talking about accessing it through sqlalchemy it means the model was queried).

Also I'm not sure I got the reference to read only data, file metadata is not read-only, it changes whenever you change the file.