Chunking data into a PostgreSQL bytea column? I have column of type bytea in PostgreSQL database.

If I update a row, is it possible to chunk the data into the bytea column in several small steps?

The size of one bytea entry will be mostly below 200MByte. 

The chunks will be about 1MByte.

I use psycopg2 and Python to access the db.

This is a follow-up question of Store HTTP response in PostgreSQL
If I update a row, is it possible to chunk the data into the bytea column in several small steps?


Yes, it's possible. But it's a horrible idea. PostgreSQL, and all MVCC databases, writes a new row with every update so on the last chunk you'll be writing 200 MB not 1 MB.

You may consider large_objects to get around this, or better yet not using a database for this because databases are not file systems, and instead just using an IO buffer or the file system write cache. If you need to link that to data in a database, try a path. That's what they're there for (internally the file system uses inodes). Check out btrfs or zfs if you want the PostgreSQL of file systems.

PostgreSQL is the best tool for the job if you're doing the right job, but it's not the best tool for any job.