Results 1 to 13 of 13
  1. #1
    ry94080 is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2019
    Posts
    29

    ADO data import causing database bloat

    Hi all,



    I have a process where i'm importing a an unformatted text file via ADO. It's seems to work, but seems to be causing database bloat as the databas is corrupting for being >2 gigabytes. However, when i compact and repair that same database with the data imported, it is only like 50 MBs.

    Some of the code i'm using to write to tables is seen below. I seem to be closing properly? What could be causing this bloat?

    Code:
    Function AppendMSTRecord(ByRef tMSTRecord As MSTRecord) As MSTRecord
    
    
    
    
    Dim oRST As ADODB.Recordset
    Dim sSQL As String
    
    
    sSQL = "Select * From tblMST"
    Set oRST = New ADODB.Recordset
    With oRST
        .Open sSQL, Application.CurrentProject.Connection, adOpenDynamic, adLockBatchOptimistic
        .MoveLast
            Select Case eRecordLevel
                Case 2
                    .Fields("Battery").Value = tMSTRecord.Battery
                    .Fields("LabLoc").Value = tMSTRecord.LabLoc
                    .Fields("Priority").Value = tMSTRecord.Priority
                    
                Case 3
                    .Fields("CollectDateTime").Value = tMSTRecord.CollectDateTime
                    .Fields("ReceiveDateTime").Value = tMSTRecord.ReceiveDateTime
                    .Fields("SetupDatetime").Value = tMSTRecord.SetupDatetime
                    
                Case 4
                    .Fields("CollectTech").Value = tMSTRecord.CollectTech
                    .Fields("ReceiveTech").Value = tMSTRecord.ReceiveTech
                    .Fields("SetupTech").Value = tMSTRecord.SetupTech
                Case 5
                    .Fields("CollecttoReceive").Value = tMSTRecord.CollecttoReceive
                    .Fields("ReceivetoSetup").Value = tMSTRecord.ReceivetoSetup
                    .Fields("CollecttoSetup").Value = tMSTRecord.CollecttoSetup
            End Select
        .UpdateBatch
        .Close
    End With
    Set oRST = Nothing
    End Function
    
    Function AddMSTRecord(ByRef tMSTRecord As MSTRecord) As MSTRecord
    Dim oRST As ADODB.Recordset
    Dim sSQL As String
    
    
    sSQL = "Select * From tblMST"
    Set oRST = New ADODB.Recordset
    With oRST
        .Open sSQL, Application.CurrentProject.Connection, adOpenDynamic, adLockBatchOptimistic
        .AddNew
         
        .Fields("AccNo").Value = tMSTRecord.AccNo
        .Fields("Patient").Value = tMSTRecord.Patient
        .Fields("PatLoc").Value = tMSTRecord.PatLoc
        
        
        
        .UpdateBatch
        .Close
    End With
    Set oRST = Nothing
    End Function

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    there is no reason to loop thru a recordset using code,
    thats what queries are for. (without any code)

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,979
    Are you saying it goes from 50MB to 2GB each time? How big is this text file?
    Why use ADO for this as you are adding records from an imported text file?
    Why use a recordset at all when an append query could probably be used?

    Suggest you link to the text file and then use one or more append queries to add the data to your main table.
    At most, you may need four append queries for each value in the Select Case section.
    If necessary you can use a buffer table AKA staging table if any processing needs to be done first.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    ry94080 is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2019
    Posts
    29
    Hello, it is not an imported text file, i'm opening up the text file via VBA and i have to loop through each line to parse it in different ways. It's not very "clean". The file is pretty big. The parsing works, but adding records seem to bloat.

  5. #5
    ry94080 is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2019
    Posts
    29
    The text file is generated through an automated process and is not very "clean". I'm looping through each line of the text file and having to parse the lines into columns depending on different criteria.

  6. #6
    ry94080 is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2019
    Posts
    29
    Quote Originally Posted by ranman256 View Post
    there is no reason to loop thru a recordset using code,
    thats what queries are for. (without any code)


    Is there anything i can do VBA wise so that the database doesn't bloat?

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    perhaps show, or better provide, an example of the text file with some data plus where they need to appear in tblMST as I'm not seeing anything that means you can't use a couple of append queries

    and where does eRecordLevel come into it?

  8. #8
    ry94080 is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2019
    Posts
    29
    Quote Originally Posted by Ajax View Post
    perhaps show, or better provide, an example of the text file with some data plus where they need to appear in tblMST as I'm not seeing anything that means you can't use a couple of append queries

    and where does eRecordLevel come into it?
    eRecordLevel is built to define how to write to the table. When a line starts with Acc#, the top record. It will create a new record for that line. All of the following lines after that will append the information to the same record based on the fields defined. When it sees another Acc#, which is a new record in the table, it will create again, then append the rest and so on and so forth.

    Below is an example of what should be 1 record. It's on the text file in multiple lines. I get 10 of thousands of these lines in 1 file that i need to parse into 1 record into Access. It used to work, but it seems that the file has gotten bigger recently.

    ------------------
    Acc # : F111111 Patient : TEST,TEST + (111111) Pat Loc : PN ICU STEP DOWN {PCPN}
    Battery : CULT, AFB w/Smr, PCR Lab Loc : Lab Priority :


    Collect : 05/13/2022 (1235) Receive : 05/13/2022 (1400) Setup : 05/13/2022 (2220)
    Tech : COLLECTED,BY N+ (2999) Tech : TECHNOLOGIST (2788) Tech : SETUP TECH (25249)


    Collect to Receive : 01:25 Receive to Setup : 08:20 Collect to Setup : 09:45
    ----------------------------------------------------------------------------------------------------------


    I'm attaching a picture, the text does not appear to be lined up like the textfile does.
    Click image for larger version. 

Name:	mst.JPG 
Views:	22 
Size:	34.7 KB 
ID:	48001
    Last edited by ry94080; 06-07-2022 at 11:38 AM. Reason: add picture

  9. #9
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    hmm - source data looks like it is tab delimited into 3 columns so I reckon it can be done in sql with a small amount of help with VBA. Happy to give it a go if you can upload a sample text file - say 20 or 30 records plus highlight what value you are importing (e.g. for collect 05/13/2022 (1235) or 05/13/2022?, for patient TEST,TEST + (111111) or TEST,TEST?, etc). Objective being to reduce bloat.

  10. #10
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I would be interested is seeing your dB - maybe with 3 records - change any sensitive data.
    And the text file with 3 or 4 complete records (from Acc # to the following Acc #)


    The numbers in parenthesis are times?
    Collect : 05/13/2022 (1235)
    Receive : 05/13/2022 (1400)
    Setup : 05/13/2022 (2220)

    These are just times?
    Collect to Receive : 01:25
    Receive to Setup : 08:20
    Collect to Setup : 09:45



    Argh.... too slow, again!
    Ajax has some fast fingers
    Last edited by ssanfu; 06-07-2022 at 07:35 PM.

  11. #11
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    I have an example of a parser that uses keywords and a temp table template that might be adapted to work for you:
    http://forestbyte.com/ms-access-util...rser-importer/

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  12. #12
    ry94080 is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2019
    Posts
    29
    Quote Originally Posted by ssanfu View Post
    I would be interested is seeing your dB - maybe with 3 records - change any sensitive data.
    And the text file with 3 or 4 complete records (from Acc # to the following Acc #)


    The numbers in parenthesis are times?



    These are just times?





    Argh.... too slow, again!
    Ajax has some fast fingers
    Hello, sorry for late reply. I've been testing. Yes, numbers in parenthesis are times.

    However, i believe i've found a solution. After browsing more threads on this forum, it appears someone else had similar issues in the post below:

    https://www.accessforums.net/showthread.php?t=65264

    After following his steps: "File -> Options -> Client Settings -> Advanced" and uncheck the "Open databases by using record-level locking" with "no locks" as the default record locking method.

    The database no longer bloats nearly as much.

    Thanks Everyone!!!!

  13. #13
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    It is great you found a workaround.
    Still, I would have liked to see the dB and the text file. I think the code could/might be tweaked to be a little faster - and I would use DAO.

    Good luck with your project...

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Database Bloat on DAO CommitTrans by 400 kb/commit
    By angeleumbra in forum Programming
    Replies: 7
    Last Post: 06-09-2022, 11:17 AM
  2. Huge Database BE Bloat
    By Brice in forum Access
    Replies: 6
    Last Post: 12-07-2020, 08:18 AM
  3. Back end database bloat
    By vicsaccess in forum Access
    Replies: 6
    Last Post: 06-14-2016, 12:22 PM
  4. MS Updates causing bloat???
    By JasonMann1979 in forum Access
    Replies: 7
    Last Post: 11-02-2013, 12:13 PM
  5. Replies: 8
    Last Post: 11-01-2013, 01:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums