How to store video in a PostgreSQL database?

I store image files (e.g. jpg , png ) in a PostgreSQL database. I found information on how to do this here .

Similarly, I want to store the video in a PostgreSQL database. I was looking for a network - some say you should use a data type such as bytea to store binary data.

Can you tell me how to use the bytea column to store the video?

+4
source share
3 answers

I usually do not recommend storing huge blobs (binary large objects) inside PostgreSQL unless referential integrity is your basic requirement. Storing huge files in the file system is much more efficient:
Much faster, less disk space, easier backup.

I wrote a more complete assessment of the parameters that you received in the previous answer to a similar question. (With deep links to the manual.)

+11
source

We did some tests about the practical limitations of the bytea data type. There is a theoretical limit of 1 GB. But the practical limit is about 20 MB. Processing large data bytea requires too much RAM, and encoding and decoding takes some time. Personally, I do not think that storing video is a good idea, but if you need it, then use large objects - blobs.

+6
source

Not knowing which programming language you are using, I can give a general approach:

  • Create a table with a column of type 'bytea'.
  • Get the contents of the video file in a variable.
  • Insert a row into this table with this variable as the data for the bytea column.
0
source

Source: https://habr.com/ru/post/1392449/


All Articles