Solved

The need to compact Access database

Posted on 2010-11-11
4
438 Views
Last Modified: 2012-05-10
I have simple JET database in my application: one table, 9 text columns with limited width, indexed by first column [ID] - see code. This table is accessed using connection string like "'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=MyData.mdb;Persist Security Info=False" (more specifically I'm using Delphi 6 and TADOTable/TADOQuery). From time to time the content is to be replaced by external data (approximatively 13000 records in .csv file, 500 kb size). The way I'm doing it:

for every record read from .csv
  try
    INSERT   // this produces an error if ID exists
  except
     UPDATE
   end

And now the problem.
My database is about 1Mb. After content replacing it grows to 250Mb. When I compact it then it is back to 1MB. I can use algorithm like

if record exists then UPDATE else INSERT

and then database size is stable, but it is a 100 times slower.
Is it normal behaviour or I'm doing something wrong?. The program is designed to be run on various machines and sometimes this extra 250Mb can be a problem.
The enviroment is Delphi 6, Win XP SP3, Access 2010 installed.
CREATE TABLE [players] (

  [ID] TEXT(5) NOT NULL DEFAULT '00000',

  [IMIE] TEXT(20) NOT NULL,

  [NAZWISKO] TEXT(30) NOT NULL,

  [WK] TEXT(4),

  [OKREG] TEXT(3),

  [INFO] TEXT(2),

  [KLUB] TEXT(50),

  [ZNIZKA] TEXT(1),

  [SKLADKA] TEXT(1),

PRIMARY KEY ([ID])

Open in new window

0
Comment
Question by:jfromanski
4 Comments
 
LVL 32

Assisted Solution

by:ewangoya
ewangoya earned 100 total points
Comment Utility
Checking whether the record exists is the way to do it and I'm assuming you are only checking using the primary key. It will definitely slow the import process but is much better than trying to insert then getting an error and then updating.

100 times slower is a little bit too much, I'm not sure how to re-index an Access database but it may be a worthwhile topic for you to do some research on
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 100 total points
Comment Utility
Yes, optimizing your indexes would be you first step.

FWIW, I know 250Mb seems like a lot, but this may very well be what Access needs to make it.
In today's world of Terabyte Hard drives, 250mb is minuscule...
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 300 total points
Comment Utility
"Is it normal behaviour or I'm doing something wrong?."
Pretty much normal behavior. Append records and even just updating records causes bloating. It's a fact of mdb life.  Compact & Repair does re-indexing, among other things, such as actually removing any objects that may have been deleted, records that may have been deleted and more.  In fact, it's the best preventative maintenance you can do on an Access database.

"indexed by first column [ID]"
So, you only have one index. Adding more indexes will slow down the appending process, because JET has to re-index for each record added.

"sometimes this extra 250Mb can be a problem."
How so.

Overall, I'm not really seeing a problem.

mx
0
 
LVL 10

Author Closing Comment

by:jfromanski
Comment Utility
Thanks for comments. So I will switch back to MySQL - not so easy to use and needs additional installs. BTW: I've asked this question becouse of several user's complains - all using in their clubs old Win98 desktops with 50 or 100 Mb HD
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now