??? The binary data is not tied to a physical file path; when using filesystem storage,
you must update the file paths in the referring database if you move the storage
location.
There are many practical considerations, though, depending on your DBMS??™s implementation
of large objects.
PostgreSQL
PostgreSQL has some downright weird support for binary data. There are two ways to
store binary data in a PostgreSQL database: the BYTEA data type and large objects.
The BYTEA* type is the closest thing PostgreSQL has to a BLOB type??”just a
sequence of bytes??”but it is really terrible for large amounts of binary data. The protocol
for shuttling BYTEA types back and forth from the database requires escaping
all non-printable bytes, so a single null byte would be encoded as the ASCII string
\000 (4 bytes). Needless to say, this causes unnecessary expansion of the data. In
addition, it is impossible to stream data from the database to the web browser without
running it through an unescape filter. Pulling a 2 MB binary file from the database
usually means streaming somewhere around 6 MB of data through the unescape
code.?? The na??ve method runs all of the data through Ruby strings, where it balloons
tremendously in memory. A better option would be to have the postgres C library
handle quoting and unquoting, but this is a lot of work and still suboptimal. Up to 1
GB of data can be stored in a BYTEA column.
Pages:
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161