Results 1 to 4 of 4

Thread: Advice needed...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202

    Advice needed...

    ok, so heres the situation..

    several databases, all hitting a couple million records in a single table so need to archive..nearing 2gb limit (is this a fixed limit or can i go over?)

    created archive databases, one per month, which split it to about 350Mb per database (single table)

    what i need to do is still allow the reporting of the historical data in teh monthly archives so whats the best way to do this?

    i had though create a reporting front end, ask user for start date and end date, link the relevant archives relating to these dates to allow the reporting and create custom recordsets?

    still a bit stuck as to how to create a single recordset from teh multiple archive databases without killing performance? the start database was pretty slow. network based 10Mbit LAN.

    looking for suggestions as to an implementation type to facilitate the above. will code the solution myself although examples of how you guys do things are always welcome

    TIA

    B
    if you fail to plan, you plan to fail

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: Advice needed...

    This is the VBA forum. If you're using Access, a couple million records in one table is way more than it was designed to handle. If you're using SQL server, MySQL, Oracle, etc, you might get better results in the database forum.
    Tengo mas preguntas que contestas

  3. #3
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Advice needed...

    1) Assuming you have coded linking/relinking tables, you could (in theory) relink to all the dbs (including new ones) as they are created, then run union queries to put all the totals for each month into one table then use aquery to reformat/sum these together.

    2) Or you could pull off the statistics you need as the db is archived (thus not changed?) then just link to those stats tables (which would cut your running time down) and only have the currently live month with pulling info?

    3) Upgrade to a bigger db

    4) uh, find some other way to get the data you need.

    (2) sounds like a good one, as all archived data (in theory) doesn't change, ,so if you pull off some combined stats tables and read those, you won't need to do the recalcs each time. Just unions and adding together


    Post up what you decide to do and whether it works pls (I'm curious!)

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202

    Re: Advice needed...

    ok, heres what ive done so far..
    ive also limited the reporting of data to any consecutive 90 days to aid in performance.

    VB Code:
    1. Function Link_Tables()
    2. On Error GoTo Link_Tables_Err_Click
    3.  
    4. Dim dbs As Database
    5. Dim tbfNew As TableDef
    6. Dim CurrFile As String
    7. Dim TableName As String
    8. Dim TableNameArray(5) As String
    9. Dim MyCount As Integer
    10.  
    11. 'set database and start file
    12. Set dbs = CurrentDb()
    13. CurrFile = Dir("L:\Class Data Archive\Archive\*.mdb")
    14.  
    15. 'do while still files to link
    16. Do While CurrFile <> ""
    17.  
    18. TableName = "tbl_" & Left(CurrFile, InStr(CurrFile, ".") - 1)
    19.  
    20. 'create new linked table
    21. Set tbfNew = dbs.CreateTableDef(TableName)
    22.  
    23.     'connect table and set name
    24.    With tbfNew
    25.      .Connect = ";database=L:\Class Data Archive\Archive\" & CurrFile
    26.      .SourceTableName = TableName
    27.    End With
    28.    
    29.     'update tabledefs
    30.    dbs.TableDefs.Append tbfNew
    31.    
    32.    'set to next file
    33.    CurrFile = Dir
    34.    
    35. 'repeat
    36. Loop
    37.  
    38. Create_Query:
    39. 'once tables linked create UNION query
    40. Dim qdf As QueryDef
    41. Dim strSQL As String
    42.  
    43. 'initialise count
    44. MyCount = 1
    45.  
    46. 'populate array
    47. With dbs
    48.     For Each tdf In .TableDefs
    49.         If Left(tdf.Name, 4) <> "MSys" And Left(tdf.Name, 4) <> "~TMP" Then
    50.             TableNameArray(MyCount) = tdf.Name
    51.             MyCount = MyCount + 1
    52.         End If
    53.     Next
    54. End With
    55.  
    56. 'delete existing query first
    57. DoCmd.DeleteObject acQuery, "qry_Class_Data_UNION"
    58.  
    59. 'Dynamic SQL string depending on contents of array
    60. strSQL = "SELECT " & TableNameArray(1) & ".*"
    61. strSQL = strSQL & " FROM " & TableNameArray(1) & ""
    62. strSQL = strSQL & " WHERE " & TableNameArray(1) & ".[Report Date] >= (forms!Switchboard!txtstartdate) and " & TableNameArray(1) & ".[Report Date] <=(forms!switchboard!txtenddate)"
    63. If TableNameArray(2) <> "" Then
    64.     strSQL = strSQL & " UNION SELECT " & TableNameArray(2) & ".*"
    65.     strSQL = strSQL & " FROM " & TableNameArray(2) & ""
    66.     strSQL = strSQL & " WHERE " & TableNameArray(2) & ".[Report Date] >= (forms!Switchboard!txtstartdate) and " & TableNameArray(2) & ".[Report Date] <=(forms!switchboard!txtenddate)"
    67.     If TableNameArray(3) <> "" Then
    68.         strSQL = strSQL & " UNION SELECT " & TableNameArray(3) & ".*"
    69.         strSQL = strSQL & " FROM " & TableNameArray(3) & ""
    70.         strSQL = strSQL & " WHERE " & TableNameArray(3) & ".[Report Date] >= (forms!Switchboard!txtstartdate) and " & TableNameArray(3) & ".[Report Date] <=(forms!switchboard!txtenddate)"
    71.         Else
    72.             strSQL = strSQL & ";"
    73.     End If
    74.     Else
    75.     strSQL = strSQL & ";"
    76. End If
    77.  
    78. 'create query
    79. Set qdf = dbs.CreateQueryDef("qry_Class_Data_UNION", strSQL)
    80.    
    81. Link_Tables_Exit_Click:
    82.     Exit Function
    83.  
    84. Link_Tables_Err_Click:
    85. 'table already exists
    86.     If Err.Number = 3012 Then
    87.         Resume Next
    88.         Else: MsgBox Err.Number & " " & Err.Description, vbOKOnly + vbCritical, "Error!"
    89.         Resume Link_Tables_Exit_Click
    90.     End If
    91.    
    92. End Function

    i now need to extract the month from the table name (tbl_Class_Data_January_05)
    and only link the tables relating to the start and end date input on the switchboard.

    using the criteria on the UNION SQL does improve performance..so its looking promising so far.

    thanks for the advice..I will post up when i get the chance to finish this.
    if you fail to plan, you plan to fail

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width