473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

ListBox requery is too slow

19
Good afternoon folks, I have a performance question if anybody might have suggestions.

Functionally, everything i'm about to describe works as intended. The only problem I'm having is speed.

Assume:

1) Using MS Access 2003 in an ADP project, SQL Server 2000 Enterprise backend
2) Main form is populated by a stored procedure, which works flawlessly
3) There is a listbox on the form that will display matching records based on a key field in the form's recordset.

For example, I return 10,000 records, and there's a specific field called key1. The listbox has it's own Stored Procedure behind it, and whenever I change records on the form (Utilizing OnCurrent), the listbox requeries and finds related records based on key1.

The problem I'm having is that the requery takes too long. So if you have 10 or 100,000 records on the form, even if only one or two records are returned in the listbox is takes a good 1-2 seconds to populate, meaning that navigating to other records on the form appears to "lag" as the listbox requries.

I have tried the stored procedure route for the listbox rowsource, and also building SQL on the fly via VBA to pull directly from the underlying table, and both are the same in performance. This is going to kill my users.

Any suggestions? :)
Dec 1 '07 #1
6 6026
Jim Doherty
897 Expert 512MB
Good afternoon folks, I have a performance question if anybody might have suggestions.

Functionally, everything i'm about to describe works as intended. The only problem I'm having is speed.

Assume:

1) Using MS Access 2003 in an ADP project, SQL Server 2000 Enterprise backend
2) Main form is populated by a stored procedure, which works flawlessly
3) There is a listbox on the form that will display matching records based on a key field in the form's recordset.

For example, I return 10,000 records, and there's a specific field called key1. The listbox has it's own Stored Procedure behind it, and whenever I change records on the form (Utilizing OnCurrent), the listbox requeries and finds related records based on key1.

The problem I'm having is that the requery takes too long. So if you have 10 or 100,000 records on the form, even if only one or two records are returned in the listbox is takes a good 1-2 seconds to populate, meaning that navigating to other records on the form appears to "lag" as the listbox requries.

I have tried the stored procedure route for the listbox rowsource, and also building SQL on the fly via VBA to pull directly from the underlying table, and both are the same in performance. This is going to kill my users.

Any suggestions? :)

If you are populating the list box via stored procedure there should not be a speed issue. Do you have indexes properly set on the server specific for your needs ie: on SELECT and WHERE clause columns? and calling back only the columns you need and sufficient row depth ie not falling into the trap of SELECT * from blah then only displaying 2 columns in the listbox and so on. Without knowing the design of your db, server optimisation its somewhat difficult working blind here

Regards

Jim :)
Dec 1 '07 #2
binky
19
The table i'm pulling from has about 20 columns, and i'm grabbing six of them. All the fields in my select and where clauses happen to be indexed, so that shouldn't be an issue.

I think it's less of a server problem and more of a client problem, i.e. the listbox.requery command that's causing it.
Dec 1 '07 #3
Jim Doherty
897 Expert 512MB
The table i'm pulling from has about 20 columns, and i'm grabbing six of them. All the fields in my select and where clauses happen to be indexed, so that shouldn't be an issue.

I think it's less of a server problem and more of a client problem, i.e. the listbox.requery command that's causing it.
hmm ..how are you populating the listbox? I,ve never had a problem on this with listboxes and am running Acc2000 adp's and sql Server2000

Jim
Dec 1 '07 #4
binky
19
I tried two different methods: using a stored procedure and building the SQL source on the fly.

Building it dynamically:

Expand|Select|Wrap|Line Numbers
  1. lstSearch.RowSource = "SELECT  key_field2 AS k2, key_field3 AS k3, key_field4 as k4, key_field5 as k5, err_field1 as e1, err_field2 as e2 FROM cv WHERE cv.key_field1 = '" & key_field1 & "'"
  2.  
  3. lstSearch.Requery
  4.  
  5.  
The stored procedure is exactly the same query, although it uses the parameter @key_field1 which is passed from the form (from the form control "key_field1").
Dec 3 '07 #5
Jim Doherty
897 Expert 512MB
I tried two different methods: using a stored procedure and building the SQL source on the fly.

Building it dynamically:

Expand|Select|Wrap|Line Numbers
  1. lstSearch.RowSource = "SELECT key_field2 AS k2, key_field3 AS k3, key_field4 as k4, key_field5 as k5, err_field1 as e1, err_field2 as e2 FROM cv WHERE cv.key_field1 = '" & key_field1 & "'"
  2.  
  3. lstSearch.Requery
  4.  
  5.  
The stored procedure is exactly the same query, although it uses the parameter @key_field1 which is passed from the form (from the form control "key_field1").

Hi Binky,

I do not see anything wrong with the SQL other than to make this observation..... if...... that is a straight lift from your on current procedure you are requerying the listbox twice by first setting the rowsource and then using the line lstSearch.requery. The setting of the rowsource dynamically like that is sufficient to cause the list to requery itself. As is you are firing off two SELECT commands to the server and it is having to pull back two recordsets back. (You only see the one of course) but that may be one reason for your delay?

You are obviously aware that a stored procedure is the optimum method for pulling back the records because of its pre-compiled execution plan. When you have used an SP in the past I'm rather guessing/hoping your syntax is the following method for doing that in the on current event? if not then try it out.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Me!Listbox.rowsource="EXEC dbo.MyStoredProcedureName '"&Me!key_field1 &"'"
  3.  
I say this because I've seen a number of occasions overly large procedures created at module level simply to populate a listbox
because some good people perceive the only way of pulling back a dataset from the server is by using the command object method creating parameters, appending parameters to collections opening recordsets and all sorts of convoluted code within a functional procedure when the simplest of lines does the job.

As an aside, If it does have to pull back 'many many' records per main form record, then the practical advice is to fire the query only by activation of a button 'Fetch List' or something like that and design your app around that. You will be paying homage to the networking guys who for once will be seeing a develpper who is actually restricting network traffic :)))

If the row depth of the listbox is only a few records each time then generally this shouldnt be an issue but if it has to contend with huge datasets then the fundamental principle of 'performance versus overhead' in designing your app has to be taken into account.

I'm not sure I,ve helped but I hope this helps a little

Regards

Jim :)
Dec 4 '07 #6
binky
19
I contimplated having a toggle button that will turn the box on and off, but the users really want it on all the time.

I tried:

Expand|Select|Wrap|Line Numbers
  1. lstSearch.RowSource = "EXEC dbo.usp_ssn_exception_srch '" & Combo102 & "', '" & Combo143 & "', '" & key_field1 & "'"
The above works, but actually seems to run slower than the following:

Expand|Select|Wrap|Line Numbers
  1.     lstSearch.RowSource = "SELECT " & _
  2.                           "key_field2 AS K2, " & _
  3.                           "key_field4 AS K4, " & _
  4.                           "err_field1 AS E1, " & _
  5.                           "err_field2 AS E2, " & _
  6.                           "err_field3 AS E3 " & _
  7.                           "FROM cv_error_log_s2 " & _
  8.                           "WHERE prcs_nm = '" & Combo102.Value & "'" & _
  9.                           "AND err_msg = '" & Combo143.Value & "'" & _
  10.                           "AND key_field1 = '" & key_field1 & "'"
  11.                           '"ORDER BY key_field4, err_field1"
I took out the requery, and it sped it up just a little bit. But there's still a very noticable lag when you are navigating records. I suppose it will work, my users will just have to deal with it for the time being :)

Thanks for all your help, Jim. Your explanations were very informative!
Dec 4 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Annette Massie | last post by:
I would like to have a form that lists current addresses being used. On this form I would also like to have a command button that would allow the user to add an address if they do not see it...
4
by: Kyralessa | last post by:
In Access 2000, I have a base form with a ListBox of conference registrants. In the form's declarations section I include Dim f as Form To add a registrant I'm doing this: Set f = New...
1
by: M Wells | last post by:
Hi All, I am developing an Access 2003 project application with the back end in SQL Server 2003. I have a master form that tracks projects, and several subforms on it that track various...
7
by: Colleyville Alan | last post by:
I have an app in which users are displayed a list of mutual fund from which they can choose. There is a listbox embedded in a two-tabbed notebook control. When the form is initally opened, the...
4
by: N. Graves | last post by:
Hello... thank you for your time. I have a form that has a List box of equipotent records and a sub form that will show the data of the equipment select from the list box. Is it possible to...
3
by: RC | last post by:
I have a form where the user enters the Model info. The user picks the Model from either a combobox or listbox which both are filled from the Models table. If the Model type isn't in the boxes,...
6
by: Mark | last post by:
Hello. I have a listbox whose rowsource is set to a saved query (call it "qry_customer_list.") When I add customers to my database, I call the listbox Requery method so that the listbox will...
1
by: ANDRESUK | last post by:
All I have a listbox in a form footer. When the form footer is visible the listbox requeries fine but when I turn the form footer visible=false the listbox does not requery at all. What I am...
3
by: Prochot | last post by:
I'm trying to design a database to track projects and the associates assigned to them. I have almost no experience with this. I have three tables: -Projects -Associates -Assignments where...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.