accessNator
Registered User.
- Local time
- Today, 17:41
- Joined
- Oct 17, 2008
- Messages
- 132
Prior to splitting the database, my PassThrough query performance was acceptable.
After splitting the database, my passthrough query has become sluggish and slow where my users are not very happy.
When I run a test prior to splitting my database, it would take about 1-5 seconds to retrieve the records using a passthrough.
But after splitting, now that passthrough query will take anywhere from 3 minutes - 10 minutes.
Can anyone shed some light on this? I am using Access 2007.
Here is my code:
In my sub CompanyHistoryByPeriodTransactions, I added a couple of message boxes to gauge how long it took to/from the passthrough query. This is where I see my slow down occurring.
Thoughts?
After splitting the database, my passthrough query has become sluggish and slow where my users are not very happy.
When I run a test prior to splitting my database, it would take about 1-5 seconds to retrieve the records using a passthrough.
But after splitting, now that passthrough query will take anywhere from 3 minutes - 10 minutes.
Can anyone shed some light on this? I am using Access 2007.
Here is my code:
Code:
Private Sub CompanyHistoryByPeriodTransactions(ContainerSubFormLabel As Label, ContainerSubForm As SubForm, ContainerSubFormObject As String, passQuery As String)
Dim startMonth As String
Dim endMonth As String
startMonth = Me.cboSelectMonth & "/1/" & cboSelectYear
endMonth = DateAdd("d", -1, DateAdd("m", 1, startMonth))
' Create Sql WHERE String
Select Case Me.FrmOptionWorksheetStatus
Case 1 ' Pending
strSQL1Where = "WHERE FK_WSC_RefId = 1"
Case 2 ' Accepted
strSQL1Where = "WHERE FK_WSC_RefId = 2 and isApproved_datestamp >= '" & startMonth & "' and isApproved_datestamp <= '" & endMonth & "'"
Case 3 ' Rejected
strSQL1Where = "WHERE FK_WSC_RefId > 2 and isApproved_datestamp >= '" & startMonth & "' and isApproved_datestamp <= '" & endMonth & "'"
End Select
With ContainerSubForm
.SourceObject = "sfrmOnlineSubmissionData"
End With
Dim Table1 As String
Table1 = "tempKUSFWorksheets"
Dim strSQL1 As String
' Create Sql String From Table1
strSQL1 = "SELECT TKW_RefId, FK_WSC_RefId, isApproved, isApproved_datestamp, cast(right(cid,4) as int) as cid1, "
strSQL1 = strSQL1 & "plan_year, cut_off_date_period, currentdate, report_month, period_start, period_end, period_length, "
strSQL1 = strSQL1 & "report_basic_id, revision, "
strSQL1 = strSQL1 & "flow_thru_rev, "
strSQL1 = strSQL1 & "local_exch_serv, wpm_monthly_charge, wpm_monthly_use, voip, intrastate_swithced_toll, toll_private_line, alt_access_dir, alt_payphone, misc_charges, total_intrastate_retail_rev, "
strSQL1 = strSQL1 & "uncollectibles, "
strSQL1 = strSQL1 & "net_intrastate_revenue, "
strSQL1 = strSQL1 & "assessment_rate, lec_num_access_line, gross_assessment, "
strSQL1 = strSQL1 & "support_payable, "
strSQL1 = strSQL1 & "lifeline_num_lines1, lifeline_discount1, lifeline_num_lines2, lifeline_discount2, lifeline_support, "
strSQL1 = strSQL1 & "total_assessment, "
strSQL1 = strSQL1 & "assessment_transferred_account, assessment_transferred_amount, "
strSQL1 = strSQL1 & "net_kusf_assessment_payment, "
strSQL1 = strSQL1 & "late_penalty, "
strSQL1 = strSQL1 & "signature_name, signature_title, unique_worksheet_id, submission_db_datestamp "
strSQL1 = strSQL1 & "FROM " & Table1 & " "
strSQL1 = strSQL1 & strSQL1Where & ";"
MsgBox "1" & Now()
' Using Pass Through Query
CreateSPT passQuery, strSQL1
MsgBox "2" & Now()
Dim db As DAO.Database
Set db = CurrentDb
Dim rst1 As DAO.Recordset
Set rst1 = db.OpenRecordset(passQuery, dbOpenSnapshot)
Dim FindRecordCount As Double
If rst1.EOF Then
FindRecordCount = 0
Else
rst1.MoveLast
FindRecordCount = rst1.RecordCount
End If
If rst1.RecordCount = 0 Then
Me.Repaint
Me.txtStatus.ForeColor = vbBlue
Me.txtStatus.Value = "No Records Found"
ShowHideSubForm ContainerSubForm, ContainerSubFormObject, False
Set rst1 = Nothing
Set cn = Nothing
Exit Sub
End If
Application.RefreshDatabaseWindow ' Refresh Objects list in Access
GetTotalRecords ContainerSubFormLabel, ContainerSubForm, ContainerSubFormObject, rst1.RecordCount, 380
ShowHideSubForm ContainerSubForm, ContainerSubFormObject, False
' Populate Subform with Recordsource
Forms!frmOnlineSubmission!sfrmContainerOnlineSubmissionData.Form.RecordSource = passQuery
' Set Subform visible property, IMPORTANT: this must follow after setting RecordSource of subform
Forms!frmOnlineSubmission!sfrmContainerOnlineSubmissionData.Visible = True
Set rst1 = Nothing
Set cn = Nothing
Set db = Nothing
End Sub
Code:
Function CreateSPT(SPTQueryName As String, strSQL As String)
'Purpose: Create a parameter query or action query using ADOX.
Dim cat As Object
Dim cmd As Object
passConnServer = ConnServer
On Error GoTo ErrorHandler
Set cat = CreateObject("ADOX.Catalog")
Set cmd = CreateObject("ADODB.Command")
'Initialize.
cat.ActiveConnection = CurrentProject.Connection
Set cmd.ActiveConnection = cat.ActiveConnection
cmd.CommandText = strSQL
cmd.Properties("Jet OLEDB:ODBC Pass-Through Statement") = True
cmd.Properties _
("Jet OLEDB:Pass Through Query Connect String") = SetConnectionString(passConnServer) '1 - REMOTE SERVER AT DISCOUNT.ASP, 2 - LOCAL SERVER ON GVNW-LAB-1
'Append the Command to the Procedures collection of the catalog.
cat.Procedures.Append SPTQueryName, cmd
'Clean up.
Set cat = Nothing
Set cmd = Nothing
Exit Function
ErrorHandler:
' If Query already exists, delete it.
cat.Procedures.Delete SPTQueryName
Resume
End Function
Thoughts?