Results 1 to 11 of 11

Thread: SQL Speed

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    200

    SQL Speed

    I have VB6 program that uses SQL queries and an ADO connection to connect to a MS Access 2002 database. The database contains on an average 40,000+ records. The first screen in the program loads the contents of the database to a listbox; obviously this takes a while. The users want to maintain the ability to see everything, but want it to load faster. Is there a way to load faster via using a stored procedure in Access or something of that nature? Any suggestions are welcomed. Thanks.
    Last edited by manofsteel00; Jan 31st, 2006 at 02:01 PM. Reason: wording

    Nenio foriras ĝis ĝi havas instru ni kiu ni devas scii.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: SQL Speed

    Access .mdb files do not support Stored Procedures. There are a few things you can do to make it appear as loading faster but not much else. Are you using ADO Command Objects and Forward-Only and Read-Only recordset? They are faster.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: SQL Speed

    Although Rob has made about the only recommendation to speed things up that I can think of, even making his changes really isn't going to get you much.

    Why in the world do your customers want to see 40,000 items in a listbox? That is insane. Not only will it take time to load, but it will also take time to find stuff. Is this database going to grow? A listbox has a limit of 32K

  4. #4
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: SQL Speed

    The other thing is (on top of what's been mentioned), make sure you index the tables by the fields you use in your where clause. It'll slow your INSERT and UPDATE slightly, but your SELECTs and DELETEs get a huge boost.

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: SQL Speed

    Why not give them some options for filtering the data and seeing it all too. So at the startup you would load only the most recent data maybe and then if they want to look at it all they would use the filter to remove the filtering condition. After a while they may realize how slow it is to see everything and not use it or want it much.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    200

    Re: SQL Speed

    The program is for a cycle count (an audit for food). The user wants to be able to chose from multiple Pick slots, which is how they want to see the data. It just takes around two entire minutes to load the selection screen.

    Nenio foriras ĝis ĝi havas instru ni kiu ni devas scii.

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: SQL Speed

    Quote Originally Posted by manofsteel00
    It just takes around two entire minutes to load the selection screen.
    I can certainly understand that, but with that many records, I don't see how you are going to get around it.

    What about growth? As I mentioned, if it gets too big you could wind up with a problem. You are only going to get 32K worth of data in a standard VB listbox.

    If you foresee the number of items growing, I would encourage you to begin, now, to look around for a third party replacement for that listbox.

  8. #8
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: SQL Speed

    One of the things you may be able to do is mimic a full search without grabbing all of the records. I don't know if this is possible in VB6, but only query the TOP 1000 initially and then if they scroll to the bottom, add the next 1000 (TOP 1000 WHERE field > 'LastValueInListBox') to the listbox and continue with that. You're still heavy on the DB end, but atleast your startup cost will be lighter.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    200

    Re: SQL Speed

    How could I implement the ADO Command Objects and Forward-Only and Read-Only recordsets?

  10. #10
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: SQL Speed

    We stop loading all listbox and combo boxes at 200 row - more then that is painful for the user.

    Why are you against the suggestions you've gotten to query the user for data that will help to lessen the number of rows retrieved from the database?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  11. #11
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: SQL Speed

    You may try the Listview control instead...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

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