SQL Server 2005:复制、varbinary

发布于 2024-07-16 16:35:24 字数 1132 浏览 2 评论 0原文

场景

在我们的复制方案中,我们复制许多表,包括包含二进制图像数据的 photos 表。 所有其他表都会按预期进行复制,但 photos 表不会。 我怀疑这是因为 photos 表中的数据量较大,或者可能是因为图像数据是 varbinary 字段。 但是,使用较小的 varbinary 字段并没有帮助。

配置信息

这里是一些配置信息:

  • 每个图像可以是 65-120 Kb 之间的任何地方
  • 修订版和批准的副本与缩略图一起存储,因此单行可能接近 ~800Kb
  • 我曾经遇到过“max text repl”的问题size”配置字段,但我已使用 sp_configurereconfigure with override 将其设置为最大值
  • 照片是根据“已发布”字段进行过滤的,但是其他工作表也是如此
  • 数据库使用相同的本地数据库服务器(在开发环境中)并配置为事务复制
  • 复制的数据库使用“推送”订阅

另外,我注意到有时重新生成快照并重新初始化订阅会导致要复制的图像。 考虑到这一点,我将快照代理配置为每分钟左右重新生成一次快照以进行调试(显然这对于​​生产环境来说是多余的)。 然而,这并没有帮助事情。

问题

是什么导致 photos 表无法复制,而所有其他表都没有问题? 有没有解决的办法? 如果没有,我将如何进一步调试?

注释

我使用 SQL Server Profiler 以及复制监视器来查找错误。 不存在错误。 据我所知,该操作只是默默地失败了。

我在 Windows Server 2003 Service Pack 2 上使用带有 Service Pack 3 的 SQL Server 2005。

[更新]

我发现了一个困难的方法 Philippe Grondier 在下面的回答中绝对正确。 图像、视频和其他二进制文件不应存储在数据库中。 IIS 处理这些文件的效率比我高得多。

Scenario

In our replication scheme we replicate a number of tables, including a photos table that contains binary image data. All other tables replicate as expected, but the photos table does not. I suspect this is because of the larger amount of data in the photos table or perhaps because the image data is a varbinary field. However, using smaller varbinary fields did not help.

Config Info

Here is some config information:

  • Each image could be anywhere from 65-120 Kb
  • A revision and approved copy is stored along with thumbnails, so a single row may approach ~800Kb
  • I once had trouble with the "max text repl size" configuration field, but I have set that to the max value using sp_configure and reconfigure with override
  • Photos are filtered based on a “published” field, but so are other working tables
  • The databases are using the same local db server (in the development environment) and are configured for transactional replication
  • The replicated database uses a “push” subscription

Also, I noticed that sometimes regenerating the snapshot and reinitializing the subscription caused the images to replicate. Taking this into consideration, I configured the snapshot agent to regenerate the snapshot every minute or so for debugging purposes (obviously this is overkill for a production environment). However, this did not help things.

The Question

What is causing the photos table not to replicate while all others do not have a problem? Is there a way around this? If not, how would I go about debugging further?

Notes

I have used SQL Server Profiler to look for errors as well as the Replication Monitor. No errors exist. The operation just fails silently as far as I can tell.

I am using SQL Server 2005 with Service Pack 3 on Windows Server 2003 Service Pack 2.

[update]

I have found out the hard way that Philippe Grondier is absolutely right in his answer below. Images, videos and other binary files should not be stored in the database. IIS handles these files much more efficiently than I can.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

祁梦 2024-07-23 16:35:24

我对您的问题没有直接的答案,因为我们的标准政策始终是“绝不将(图片)文件存储在(数据库)字段中”。 我们的解决方案不仅适用于图片,而且适用于任何类型的文件或文档,现在已成为标准:

  • 我们的数据库中有一个“文档”表,其中存储文档/文件名和相关文件夹(为了获得唯一的文档/文件名,我们从“文档”表的主键/唯一标识符值生成它们)。

这个“文档”表在我们的不同订阅者之间复制,就像所有其他表一样

  • 我们有一个“文档”文件夹,并且
    子文件夹,可在我们的每个
    数据库服务器。
  • 然后,使用一些文件和文件夹复制软件(allwayssynch 是一个选项),独立于数据库复制文档文件夹。
  • 主发布者的文件夹可以通过 ftp 完全访问,用户尝试读取本地服务器上(仍然)不可用的文档时,将无法访问该文件夹。建议通过ftp客户端软件(例如coreFTP及其命令行选项)从主服务器下载它

I do not have a straight answer to your problem, as our standard policy has always been 'never store (picture) files in (database) fields'. Our solution, that applies not only to pictures but to any kind of file, or document, is now standard:

  • We have a "document" table in our database, where document/file names and relative folders are stored (in order to get unique document/file names, we generate them from the primary key/uniqueIdentifier value of the 'Document' table).

This 'document' table is replicated among our different suscribers, like all other tables

  • We have a "document" folder and
    subfolders, available on each of our
    database servers.
  • Document folders are then replicated independently from the database, with some files and folders replication software (allwaysynch is an option)
  • main publisher's folders are fully accessible through ftp, where a user trying to read a document (still) unavailable on his local server will be proposed to download it from the main server through a ftp client software (such as coreFTP and its command line options)
不知在何时 2024-07-23 16:35:24

对于这样的图像表,您是否考虑过将该文章移至单向(或双向,如果您愿意)合并出版物? 这可能会缓解您的一些问题。

With an images table like that, have you considered moving that article to a one-way (or two-way, if you like) merge publication? That may alleviate some of your issues.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文