Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

The need to compact Access database

Posted on 2010-11-11
4
Medium Priority
?
453 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 32

Assisted Solution

by:Ephraim Wangoya
Ephraim Wangoya earned 300 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 300 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 900 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

722 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