Subject Re: Regular DB maintenance?
Author Adam
> Would it be correct then to say that all calls to the DB from my app
> should always be made within a transaction which I explicitly declare?

Yes. A transaction is a wrapper around an atomic unit of work. Of
course multiple calls to the database can (and should!) occur within a
single transaction if they are the same unit of work.

For example, adding a new customer may involve inserting records into
three or four tables. All the inserts should happen in a single
transaction to make sure that if a problem occurs along the way, you
aren't left with a partial customer.

Many frameworks try and remove transaction concepts in a lowest common
denominator approach, but this causes more problems in the long run
than it solves.

>
> Can garbage collection be done by running a command, or can it only be
> done by restoring the DB?

Simply looking at a row in a table that has garbage will cause the
clean up to happen. Superserver has a dedicated thread for the task,
in classic server it is the process that hits the garbage that is
lumped with the task. So just running a select count(*) query against
a table will cause garbage collection to occur.

Running a backup also performs garbage collection on the database
(unless you tell it not to)

Adam