<bdo id='qNahT'></bdo><ul id='qNahT'></ul>
  1. <i id='qNahT'><tr id='qNahT'><dt id='qNahT'><q id='qNahT'><span id='qNahT'><b id='qNahT'><form id='qNahT'><ins id='qNahT'></ins><ul id='qNahT'></ul><sub id='qNahT'></sub></form><legend id='qNahT'></legend><bdo id='qNahT'><pre id='qNahT'><center id='qNahT'></center></pre></bdo></b><th id='qNahT'></th></span></q></dt></tr></i><div id='qNahT'><tfoot id='qNahT'></tfoot><dl id='qNahT'><fieldset id='qNahT'></fieldset></dl></div>
    <tfoot id='qNahT'></tfoot>

    <small id='qNahT'></small><noframes id='qNahT'>

    1. <legend id='qNahT'><style id='qNahT'><dir id='qNahT'><q id='qNahT'></q></dir></style></legend>

      我应该使用 MySQL blob 字段类型吗?

      时间:2023-06-25

        <bdo id='50ham'></bdo><ul id='50ham'></ul>
            <tbody id='50ham'></tbody>
          1. <small id='50ham'></small><noframes id='50ham'>

            <tfoot id='50ham'></tfoot>
                <legend id='50ham'><style id='50ham'><dir id='50ham'><q id='50ham'></q></dir></style></legend>

              • <i id='50ham'><tr id='50ham'><dt id='50ham'><q id='50ham'><span id='50ham'><b id='50ham'><form id='50ham'><ins id='50ham'></ins><ul id='50ham'></ul><sub id='50ham'></sub></form><legend id='50ham'></legend><bdo id='50ham'><pre id='50ham'><center id='50ham'></center></pre></bdo></b><th id='50ham'></th></span></q></dt></tr></i><div id='50ham'><tfoot id='50ham'></tfoot><dl id='50ham'><fieldset id='50ham'></fieldset></dl></div>
                本文介绍了我应该使用 MySQL blob 字段类型吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在努力决定是否应该在我即将开展的项目中使用 MySQL blob 字段类型.

                I am struggling to decide if I should be using the MySQL blob field type in an upcoming project I have.

                我的基本要求是,可以查看某些数据库记录,并将多个文件上传并附加"到这些记录.根据具体情况,查看所述记录可能仅限于某些人.几乎可以不受限制地上传任何类型的文件.

                My basic requirements are, there will be certain database records that can be viewed and have multiple files uploaded and "attached" to those records. Seeing said records can be limited to certain people on a case by case basis. Any type of file can be uploaded with virtually no restriction.

                所以以一种方式看待它,如果我走 MySQL 路线,我不必担心病毒的蔓延或随机的 php 文件被上传并以某种方式执行.我也有一个更简单的方法来许可和保持数据与记录密切相关.

                So looking at it one way, if I go the MySQL route, I don't have to worry about virus's creeping up or random php files getting uploaded and somehow executed. I also have a much easier path for permissioning and keeping data tied close to a record.

                另一个明显的途径是将数据存储在 webroot 之外的特定文件夹结构中.在这种情况下,我必须为文件夹/文件制定一个特殊的命名约定,以跟踪它们在数据库中引用的内容.

                The other obvious route is storing the data in a specific folder structure outside of the webroot. in this case I'd have to come up with a special naming convention for folders/files to keep track of what they reference inside the database.

                使用 MySQL blob 字段类型会影响性能吗?我担心选择一个会阻碍网站未来发展的解决方案,以及选择一个不容易维护的解决方案.

                Is there a performance hit with using MySQL blob field type? I'm concerned about choosing a solution that will hinder future growth of the website as well as choosing a solution that wont be easy to maintain.

                推荐答案

                如果您的 Web 服务器将通过 Web 提供这些上传的文件,那么如果将它们存储在文件系统中,性能几乎肯定会更好.然后,Web 服务器将能够应用 HTTP 缓存提示,例如 Last-ModifiedETag,这将有助于多次访问同一文件的用户的性能.此外,Web 服务器会在服务时自动为文件设置正确的 Content-Type.如果您将 blob 存储在数据库中,那么您最终会实现上述功能,而当您应该从您的网络服务器免费获取它们时,您将实现更多功能.

                If your web server will be serving these uploaded files over the web, the performance will almost certainly be better if they are stored on the filesystem. The web server will then be able to apply HTTP caching hints such as Last-Modified and ETag which will help performance for users accessing the same file multiple times. Additionally, the web server will automatically set the correct Content-Type for the file when serving. If you store blobs in the database, you'll end up implementing the above mentioned features and more when you should be getting them for free from your web server.

                此外,从数据库中提取大型 blob 数据可能最终成为数据库的性能瓶颈.此外,您的数据库备份可能会变慢,因为它们将备份更多数据.如果您在开发期间进行临时查询,那么在 select 语句的结果集中看到大块会很不方便.如果您只想检查上传的文件,这样做会很不方便且迂回,因为它会笨拙地存储在数据库列中.

                Additionally, pulling large blob data out of your database may end up being a performance bottleneck on your database. Also, your database backups will probabaly be slower because they'll be backing up more data. If you're doing ad-hoc queries during development, it'll be inconvenient seeing large blobs in result sets for select statements. If you want to simply inspect an uploaded file, it will be inconvenient and roundabout to do so because it'll be awkwardly stored in a database column.

                我会坚持将文件存储在文件系统上并将文件路径存储在数据库中的常见做法.

                I would stick with the common practice of storing the files on the filesystem and the path to the file in the database.

                这篇关于我应该使用 MySQL blob 字段类型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:使用 MAX 和 GROUP BY 选择所有相应的字段 下一篇:SELECT INTO 和“未声明的变量";错误

                相关文章

                <i id='fJQpO'><tr id='fJQpO'><dt id='fJQpO'><q id='fJQpO'><span id='fJQpO'><b id='fJQpO'><form id='fJQpO'><ins id='fJQpO'></ins><ul id='fJQpO'></ul><sub id='fJQpO'></sub></form><legend id='fJQpO'></legend><bdo id='fJQpO'><pre id='fJQpO'><center id='fJQpO'></center></pre></bdo></b><th id='fJQpO'></th></span></q></dt></tr></i><div id='fJQpO'><tfoot id='fJQpO'></tfoot><dl id='fJQpO'><fieldset id='fJQpO'></fieldset></dl></div>

                  1. <small id='fJQpO'></small><noframes id='fJQpO'>

                    <legend id='fJQpO'><style id='fJQpO'><dir id='fJQpO'><q id='fJQpO'></q></dir></style></legend>
                      <bdo id='fJQpO'></bdo><ul id='fJQpO'></ul>
                    <tfoot id='fJQpO'></tfoot>