我应该只在数据库中存储固定大小的数据元素吗?

时间:2022-02-06 02:15:51

If the amount of data stored within a given field of a database is unknown, and could be very large, should I store it in an external file rather than within a field in the database?

如果存储在数据库的给定字段中的数据量未知,并且可能非常大,我应该将其存储在外部文件中而不是数据库中的字段中吗?

5 个解决方案

#1


1  

You should choose a database management system which has the capability to handle large data efficiently. The database system might store it within the database file or in an external file linked to from within the database. SQL Server 2008 can do both, transparently; not sure what other systems offer.

您应该选择一个能够有效处理大数据的数据库管理系统。数据库系统可以将其存储在数据库文件中或存储在数据库内链接的外部文件中。 SQL Server 2008可以透明地完成这两项工作;不确定其他系统提供什么。

#2


2  

Do you need transactional semantics (commit, rollback) for the data? If so, then using the external file system greatly complicates life -- use the DBMS. If you don't need transactional semantics, then the file system may make sense.

您是否需要数据的事务语义(提交,回滚)?如果是这样,那么使用外部文件系统会极大地复杂化生活 - 使用DBMS。如果您不需要事务语义,那么文件系统可能有意义。

#3


1  

That's why BLOB or Memo field types were designed. They are very good at storing variable length / large objects.

这就是设计BLOB或Memo字段类型的原因。他们非常善于存储可变长度/大对象。

That being said, I would still store certain large objects using the file system instead of using a database. If the objects were very large (multi-MB each) I would consider just placing them on the file system and storing a pointer (filename) in the database.

话虽这么说,我仍然会使用文件系统存储某些大型对象,而不是使用数据库。如果对象非常大(每个多MB),我会考虑将它们放在文件系统上并在数据库中存储指针(文件名)。

#4


0  

It depends on your task. There are pluses and minuses of storing large data on the FS instead of the DB. As for the size, you can limit it in the field definition of most databases.

这取决于你的任务。在FS而不是DB上存储大数据存在优缺点。至于大小,您可以在大多数数据库的字段定义中限制它。

#5


0  

I think it might depend on how you were going to use the data. For instance, if I were storing images that would be used in a web site (Flickr or something like that), I would rather store the images as files and keep a reference in the database, rather than store image data in the database and have to reconstitute the image data each time via some HTTP handler. On the other hand, collections of large documents that need to be searched may be more useful if the text were stored in the database.

我认为这可能取决于你将如何使用这些数据。例如,如果我存储将在网站中使用的图像(Flickr或类似的东西),我宁愿将图像存储为文件并在数据库中保留引用,而不是将图像数据存储在数据库中并且每次通过一些HTTP处理程序重建图像数据。另一方面,如果文本存储在数据库中,则需要搜索的大型文档集合可能更有用。

#1


1  

You should choose a database management system which has the capability to handle large data efficiently. The database system might store it within the database file or in an external file linked to from within the database. SQL Server 2008 can do both, transparently; not sure what other systems offer.

您应该选择一个能够有效处理大数据的数据库管理系统。数据库系统可以将其存储在数据库文件中或存储在数据库内链接的外部文件中。 SQL Server 2008可以透明地完成这两项工作;不确定其他系统提供什么。

#2


2  

Do you need transactional semantics (commit, rollback) for the data? If so, then using the external file system greatly complicates life -- use the DBMS. If you don't need transactional semantics, then the file system may make sense.

您是否需要数据的事务语义(提交,回滚)?如果是这样,那么使用外部文件系统会极大地复杂化生活 - 使用DBMS。如果您不需要事务语义,那么文件系统可能有意义。

#3


1  

That's why BLOB or Memo field types were designed. They are very good at storing variable length / large objects.

这就是设计BLOB或Memo字段类型的原因。他们非常善于存储可变长度/大对象。

That being said, I would still store certain large objects using the file system instead of using a database. If the objects were very large (multi-MB each) I would consider just placing them on the file system and storing a pointer (filename) in the database.

话虽这么说,我仍然会使用文件系统存储某些大型对象,而不是使用数据库。如果对象非常大(每个多MB),我会考虑将它们放在文件系统上并在数据库中存储指针(文件名)。

#4


0  

It depends on your task. There are pluses and minuses of storing large data on the FS instead of the DB. As for the size, you can limit it in the field definition of most databases.

这取决于你的任务。在FS而不是DB上存储大数据存在优缺点。至于大小,您可以在大多数数据库的字段定义中限制它。

#5


0  

I think it might depend on how you were going to use the data. For instance, if I were storing images that would be used in a web site (Flickr or something like that), I would rather store the images as files and keep a reference in the database, rather than store image data in the database and have to reconstitute the image data each time via some HTTP handler. On the other hand, collections of large documents that need to be searched may be more useful if the text were stored in the database.

我认为这可能取决于你将如何使用这些数据。例如,如果我存储将在网站中使用的图像(Flickr或类似的东西),我宁愿将图像存储为文件并在数据库中保留引用,而不是将图像数据存储在数据库中并且每次通过一些HTTP处理程序重建图像数据。另一方面,如果文本存储在数据库中,则需要搜索的大型文档集合可能更有用。