在mysql中存储mp3文件

问题描述:

我看到许多人建议不要将mp3文件存储为blob.我不清楚为什么会这样.

I see that many people recommend not storing mp3 files as blobs. I did not get a clear explanation of why that is.

我的网站访问量很少(每分钟10次点击).到目前为止,我已经将图像文件作为blob存储在数据库表中.我在图像表上所做的唯一查询是基于单个主键的.图像渲染不是很快,但是还可以.

I have low traffic websites (10 hits a minute). So far I have stored image files in database tables as blobs. The only look up that I do on the image tables is based on a single primary key. The image rendering has not been terribly fast, but OK.

我现在需要存储音乐文件.如果我使用与图像相同的机制,它将更加简单.但是我需要了解这样做的含义.

I now have a need to store music files. If I used the same mechanism as the images, it would be simpler. But I need to understand the implications of doing that.

我会建议您.

文件系统是用于文件的,为什么不会将其存储在其中?

Filesystems are meant for files, why wouldn't you store it there?

在MySQL中,它会慢得多;您说的是进展还不是很快".如果负载增加,这将成倍增长.您可能还需要将整个BLOB加载到PHP的内存中(如果这是您使用的前端语言),这也会引起问题.

In MySQL it will be so much slower; you're saying 'it has not been terribly fast'. This will grow exponentially if load increases. You'll also likely need to load the entire BLOB into memory in PHP (if that's the front-end language you're using) which also causes issues.

完成此操作后,您会特别注意到它会增加内存使用量以及mp3开始下载/播放所需的时间.

Once you've done this, you'll especially notice it increases memory usage and the time it takes before the mp3 starts downloading/playing.