|
-
Nov 11th, 2011, 03:30 PM
#1
Thread Starter
PowerPoster
speed up query execution
for you wath code speed up the query execution:
Code:
....
SQL = "SELECT SP from tab1 WHERE DT='" & Me.DT3.Text & "'GROUP BY SP"
....
Set RST0 = New ADODB.Recordset
With RST0
.CursorType = adOpenKeyset
.CursorLocation = adUseClient
.LockType = adLockReadOnly
End With
Set CMD = New ADODB.Command
With CMD
.CommandTimeout = 0
.CommandText = SQL
.ActiveConnection = CONN
.CommandType = adCmdText
'.Prepared = True
DoEvents
Set RST0 = .Execute
Set CMD = Nothing
End With
....
or directlly:
Code:
With RST0
.CursorType = adOpenKeyset
.CursorLocation = adUseClient
.LockType = adLockReadOnly
End With
Set RST0= New ADODB.Recordset
RST0.Open sql, CONN, adOpenKeyset, adLockOptimistic, adCmdtext
note:
are approx 75.xxx records in access table:-(
Last edited by luca90; Nov 19th, 2011 at 04:00 PM.
-
Nov 18th, 2011, 01:50 PM
#2
Re: speed up query execution
Your query looks pretty simple (although it's not recommended to just concatenate strings to your WHERE clause, as it opens your application for SQL Injections, use parametrized query instead ). But in any case, make sure your table has indexes on fields you used in WHERE clause and ORDER BY. In your case, check the table and make sure it has indexes on DT and SP fields.
-
Nov 18th, 2011, 02:47 PM
#3
Re: speed up query execution
I'm surprised it runs at all... it's an incomplete SQL Statement...
-tg
-
Nov 19th, 2011, 06:14 AM
#4
Thread Starter
PowerPoster
Re: speed up query execution
 Originally Posted by techgnome
I'm surprised it runs at all... it's an incomplete SQL Statement...
-tg
Is new for me... my queru run!
Suggest me where is incomplete.
Tks
-
Nov 19th, 2011, 01:25 PM
#5
Hyperactive Member
Re: speed up query execution
Code:
SQL = "SELECT SP tab1 WHERE DT='" & Me.DT3.Text & "'GROUP BY SP"
I think there should be a "From tab1" and if you are using a "GROUP BY" there should be some aggegate function like a sum, count, average, etc.
-
Nov 19th, 2011, 04:02 PM
#6
Thread Starter
PowerPoster
Re: speed up query execution
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|