Actual storage
and performance depend on the wire protocol being used, buffer size, and available
memory. Storage is efficient, using up to 4 bytes to store the data length,
followed by the binary data itself. However, MySQL suffers from issues similar to
PostgreSQL with streaming data, and it is always more awkward for a web application
to stream data from the database than from the filesystem.
Oracle
Oracle supports the BLOB data type, for objects up to 4 GB. It is supported by a
fairly mature API, and can be used directly from Rails.
Oracle also provides the BFILE type, which is a pointer to a binary file on disk. Consider
it a formalization of the filesystem storage method discussed below. This may
prove to be of value in some situations.
Filesystem Storage
The reality is that filesystem storage is the best option, as a general rule. Filesystems
are optimized to handle large amounts of binary and/or character data, and they are
fast at it. The Linux kernel has syscalls such as sendfile( ) that work on physical
files. There are hundreds of third-party utilities that you can only leverage when
using physical files:
??? Image processing is arguably the most popular application for storing binary
data. Programs like ImageMagick are much easier to use in their command-line
form, operating on files, rather than getting often-problematic libraries like
RMagick to work with Ruby.
Pages:
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163