Solved

The need to compact Access database

Posted on 2010-11-11
4
447 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
ID: 34112145
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
ID: 34115195
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 - Microsoft MVP, Access and Data Platform) earned 300 total points
ID: 34115620
"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
ID: 34120734
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 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