+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / How can I stop Sitefinity from writing to the sf_VrsBinData table?

How can I stop Sitefinity from writing to the sf_VrsBinData table?

8 posts, 0 answered
  1. Mike
    Mike avatar
    8 posts
    Registered:
    23 Apr 2009
    23 Sep 2009
    Link to this post
    I'm using the community edition version 3.6 SP2 and I'm trying to implement a custom storage provider so that I can save large files outside of the database.  My provider inherits the default libraries provider and overrides the OnExecuting event handler so that I can choose where to save the files (I also set the binary value of the Content property to null during this event so that the file is not saved to the database).  This all seems to work correctly, but my problem is that the database keeps growing in size even though I'm not saving any files to the database.  Every time I upload a file, there are 3 new records created in the sf_VrsBinData table, which are taking up a lot of space (basically the full size of each of the files I've uploaded).  I believe these records have something to do with the Versioning system, but I have versioning disabled on all providers.  Why does it still write the binary files to this table?  How can I get the system to stop writing these records to the database?  Is there a function I can override to stop this from happening?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 Sep 2009
    Link to this post
    Hello Mike,

    Most probably you are writing the bytes to the database as well. You should store zero bytes for the content or 1 byte. Otherwise the item.content ( which is object) is stored to the file system and to the database as well.

    example

    cnt.Content = ((byte[])cnt.Content)[0]; 
     
    // or 
     
    cnt.Content = new byte[0];  

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Mike
    Mike avatar
    8 posts
    Registered:
    23 Apr 2009
    24 Sep 2009
    Link to this post
    I'm already using the exact code that's in your example.  The problem is that Sitefinity has already written the bytes to the sf_VrsBinData table by the time my code executes.  In testing I found that the built-in Amazon S3 provider behaves exactly the same way - if you use it to upload a very large file, the database grows by at least the size of that file, and it seems that the extra size is contained in the sf_VrsBinData table.  Since versioning is off, why does it write to this table at all?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Sep 2009
    Link to this post
    Hello Mike,

    We tested some scenarios and it tuned out that adding data to this table cannot be stopped because the transaction from the default provider is committed before setting the content size. The workaround will require implementing a new provider and use it instead Telerik.Libraries.Data.DefaultProvider. 

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Mike
    Mike avatar
    8 posts
    Registered:
    23 Apr 2009
    28 Sep 2009
    Link to this post
    OK, thanks for looking into this.  I think instead of creating a new provider from scratch, I'll just delete the data from the table after it's written - not an ideal solution, but at least it's simple and will keep me from running out of space due to the database growing indefinitely.
  6. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    08 Oct 2009
    Link to this post
    is sf_VrsBinData only used for images/documents data?

    I am no longer using the libraries module, and want to know if I can safely truncate the table and not lose data from any other modules/pages that use this table

    thanks!
  7. Mike
    Mike avatar
    8 posts
    Registered:
    23 Apr 2009
    08 Oct 2009
    Link to this post
    This article has a little bit of info about truncating that table: http://www.sitefinity.com/support/kb/sitefinity-3-x/how-to-reduce-the-project-database-size.aspx - I believe the only data in that table is from previous versions of uploaded files, but I can't say for sure.  Maybe someone from Telerik could give you a more definitive answer.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    14 Oct 2009
    Link to this post
    Hi Mike,

    The table contains only binary data from Images and Documents module, which does not support versioning and there are not any other versions than 1.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
8 posts, 0 answered