Results 1 to 6 of 6

Thread: speed up query execution

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,927

    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.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    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.

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: speed up query execution

    I'm surprised it runs at all... it's an incomplete SQL Statement...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,927

    Re: speed up query execution

    Quote Originally Posted by techgnome View Post
    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

  5. #5
    Hyperactive Member
    Join Date
    Jul 2007
    Posts
    479

    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.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,927

    Re: speed up query execution

    Quote Originally Posted by techgnome View Post
    I'm surprised it runs at all... it's an incomplete SQL Statement...

    -tg
    corret with suggestion rasinc...
    sorry... but copy and paste with a pice of code i have the from statement

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