8

What database does Subversion use?

Is there a default or can you set it up to use any DB?

bahrep
  • 29,961
  • 12
  • 103
  • 150
Albert Muniz
  • 83
  • 1
  • 1
  • 6

3 Answers3

9

Server

Subversion supports two back ends at current for storing repositories. You can choose which with the --fs-type option to the svnadmin create command.

  1. FSFS (this is a default) which is a custom format stored with somewhat human readable files (the major exception is that delta data is binary). FSFS also uses a SQLite database for tracking hashes of file content so existing content storage can be reused if identical content needs to be stored again (depuplication). If you're thinking of a typical relational database, the SQLite usage in FSFS is the closest it gets and the SQLite db doesn't actually store any data and can be deleted with no data loss at any time (consequence is future revisions might take up more space). FSFS has had significant amounts of work done on it to optimize it for a variety of situations and has grown a number of knobs to be able to make it optimal even for unusual situations.

  2. BDB (this is the original back end) which uses the Berkeley DB to store the repository. As of 1.8.0 this back end is deprecated but still supported. It has not had a lot of work done to it in a long time and FSFS will outperform it in almost all cases.

There has been at least one other back end implementation by Google, which was never released using Google's proprietary BigTable storage. I believe this is actually still used for GoogleCode's Subversion support.

Subversion 1.9.0 (not released at the time of this writing) will support a new experimental storage called FSX (pronounced like physics) which will be much more compact and faster than FSFS. It's expected that once FSX is considered stable that BDB will be removed entirely.

Subversion does not support using other general purpose databases like MySQL, PostgreSQL, Oracle and others (RDBMS or NOSQL) for storing all the content at all and there are no plans to support them at this point.

Client

For the client side working copy the Subversion client has used two different formats

  1. WCv1 (doesn't exactly have a name but that's what we've taken to calling it now) which used flat files in a .svn directory under every directory of the working copy. This was used by Subversion up until 1.7.0 when we changed to WC-NG.

  2. WC-NG which uses a SQLite database in the .svn directory at the top level of the working copy. This is used by Subversion since 1.7.0.

Ben Reser
  • 5,695
  • 1
  • 21
  • 29
7

Subversion uses FSFS and you neither can nor should ever want to change it.

zerkms
  • 249,484
  • 69
  • 436
  • 539
  • 2
    While you're right that you shouldn't ever want to switch from FSFS at this point, you actually can use BDB with the `--fstype` option to `svnadmin create` – Ben Reser Jan 21 '14 at 23:36
  • @Ben Reser: I was mostly answering: "can you set it up to use any db". But indeed, a bit unclear – zerkms Jan 21 '14 at 23:39
  • @zerkms, Why doesn't SVN use sqlite instead? – Pacerier Apr 04 '15 at 15:19
  • SVN was first released in October 2000. Sqlite 1.0 was only released two months earlier. The SVN developers likely chose a database solution based on the options that were available, well-known, and stable in early 2000 or before. – Jim Grisham Jul 18 '22 at 16:11
  • _(see [history of BerkleyDB use in SVN](https://svnbook.red-bean.com/en/1.7/svn.reposadmin.planning.html#svn.reposadmin.basics.backends.bdb))_ – Jim Grisham Jul 18 '22 at 16:20
  • 1
    @JimGrisham that's really interesting (genuinely, not being snarky), thanks for the link! – zerkms Jul 19 '22 at 23:10
5

For storing the repository contents, Subversion uses its own FSFS database. It's not a database in the relational database sense. It's a filesystem-based method of storing repository contents.

For some server-side functionality, and for storing working copy metadata on the client end, it uses SQLite.

You can't change either of these decisions, nor should you go mucking about in these structures unless you know exactly what you are doing.

alroc
  • 27,574
  • 6
  • 51
  • 97
  • "unless you know exactly what you are doing" --- and if you did - you wouldn't ask about it :-) Nice answer – zerkms Jan 21 '14 at 21:36