Print Page | Close Window

shrinking the database

Printed From: LogSat Software
Category: Spam Filter ISP
Forum Name: Spam Filter ISP Support
Forum Description: General support for Spam Filter ISP
URL: https://www.logsat.com/spamfilter/forums/forum_posts.asp?TID=4352
Printed Date: 04 June 2025 at 4:21am


Topic: shrinking the database
Posted By: Guests
Subject: shrinking the database
Date Posted: 27 September 2004 at 1:53pm

I am on version 2.1.1.367 and I would like to shrink my SQL database which has grown a lot what is the best way to do it




Replies:
Posted By: LogSat
Date Posted: 28 September 2004 at 12:37am
Raman,

What kind of database platform are you using? MS Access has an option to shrink a database, with SQL server there are other procedures that usually DBA's follow to maintain the transaction logs.

Roberto Franceschetti LogSat Software


Posted By: sgeorge
Date Posted: 02 December 2005 at 10:15am
Roberto, my quarantine db is being written to an MS Access file.  To my understanding, the only way to shrink the database is to stop SpamFilter, open the database in Microsoft Access, shrink the db, and then restart SpamFilter.  Is there another way to do this without temporarily stopping the program?

Thanks,

Stephen


Posted By: LogSat
Date Posted: 02 December 2005 at 5:20pm

Stephen,

Unfortunately this is also the only way we know of. Access was really designed to be a single-user database, and Microsoft is having a real hard time into trying to make it a real multi-user platform.



-------------
Roberto Franceschetti

http://www.logsat.com" rel="nofollow - LogSat Software

http://www.logsat.com/sfi-spam-filter.asp" rel="nofollow - Spam Filter ISP


Posted By: sgeorge
Date Posted: 07 February 2006 at 10:09am
Hi, I thought I would just post a windows .bat file that has been helpful for me in shrinking my Access DB.  Generally, I make a copy of my Spamfilter database, run some queries on it to remove dead-obvious spam from the DB, and then I stop the SpamFilter service and swap-in the shrunk database in place of the working database.

Here's my batch file...

Important Notes:
  1. This has only been tested on Windows Server 2003
  2. This only works if you are running SpamFilter as a service and are using MS Access files as your database
  3. It assumes that it can find your database (and the "shrunk" copy) in c:\Program Files\SpamFilter\Database -- modify that path to fit where you save your SpamFilter quarantine
  4. SpamFilter.mdb: The database that the SpamFilter service is actively using
  5. SpamFilter2.mdb: The "offline" database that you have "shrunk" and want to swap-in
-----------------------------------

@echo off

set SPAMFILTER_SERVICE_NAME=SpamFilter
set FILE_MOVE_FROM=SpamFilter2.mdb
set FILE_MOVE_TO=SpamFilter.mdb


echo *****************************************************
echo Moving SpamFilter2.mdb to SpamFilter.mdb and
echo restarting SpamFilter...
echo *****************************************************
echo Hit Ctrl and c to cancel, starting in 3 seconds...
@ping 127.0.0.1 -n 2 -w 1000 > nul
echo Hit Ctrl and c to cancel, starting in 2 seconds...
@ping 127.0.0.1 -n 2 -w 1000 > nul
echo Hit Ctrl and c to cancel, starting in 1 second...
@ping 127.0.0.1 -n 2 -w 1000 > nul
echo Replacing Database...


:begin
c:
set object=c:\Program Files\SpamFilter\Database
cd %object%
if not %ERRORLEVEL% == 0 goto error_directory_change

if not exist %FILE_MOVE_FROM% goto error_no_file


rem *** Checks Passed - Proceed ***

net stop %SPAMFILTER_SERVICE_NAME%
if not %ERRORLEVEL% == 0 goto error_no_stop

@ping 127.0.0.1 -n 1 -w 1000 > nul

move /Y %FILE_MOVE_FROM% %FILE_MOVE_TO%
if not %ERRORLEVEL% == 0 echo Warning: %FILE_MOVE_FROM% could not be moved to %FILE_MOVE_TO%.  Be sure that %FILE_MOVE_TO% is not marked as read-only.  Attempting to restart SpamFilter...

net start %SPAMFILTER_SERVICE_NAME%
if not %ERRORLEVEL% == 0 goto error_no_start


echo Success!
goto quit




:error_directory_change
echo Could not change to directory: %object%
goto quit

:error_no_file
echo The file does not exist: %FILE_MOVE_FROM%
goto quit

:error_no_stop
echo The service "%SPAMFILTER_SERVICE_NAME%" could not be stopped.  Be sure the service exists and is running.
goto quit

:error_no_start
echo The service "%SPAMFILTER_SERVICE_NAME%" could not be started.  Be sure the service exists.
echo SpamFilter IS NOT RUNNING!
goto quit

:quit
@ping 127.0.0.1 -n 5 -w 1000 > nul




Print Page | Close Window