I have created a list box in a Wine tracking form from which I can pick one of about 12,000 wineries. It then successfully puts the associated WineryID into the Wine record. But it takes about 35 seconds to populate the listbox's list. And when I move to the next wine record, it takes another 35 seconds to display that next record. This makes navigating through my database intolerably slow.
I have read about the virtual listbox for other DBMSs: http://wiki.tcl.tk/10035. Is there a way to create that kind of functionality in a Base form? Or any other way to speed things up? My Winery column is of type tinytext and I have indexed the first 30 characters of it. I am connecting to MySQL via ODBC.
[Solved] How do I speed up a very slow listbox?
-
- Posts: 18
- Joined: Thu Apr 10, 2008 5:34 am
- Location: Manchester, NH
[Solved] How do I speed up a very slow listbox?
Last edited by JDHeinzmann on Mon May 05, 2008 3:20 am, edited 1 time in total.
JD
MySQL 5.0.45-community-nt, OOo 3.3.1, ODBC 5.1, Win XP Pro SP2.
MySQL 5.0.45-community-nt, OOo 3.3.1, ODBC 5.1, Win XP Pro SP2.
-
- Posts: 18
- Joined: Thu Apr 10, 2008 5:34 am
- Location: Manchester, NH
Re: How do I speed up a very slow listbox?
I just discovered that if I specify the "Type of list contents" to be SQL [Native], the listbox populates about 7 times faster! Why would that be?
Even though this is a nice speed up (no longer glacially slow), navigation is still slow. Anybody have any other ideas?
Even though this is a nice speed up (no longer glacially slow), navigation is still slow. Anybody have any other ideas?
JD
MySQL 5.0.45-community-nt, OOo 3.3.1, ODBC 5.1, Win XP Pro SP2.
MySQL 5.0.45-community-nt, OOo 3.3.1, ODBC 5.1, Win XP Pro SP2.
-
- Posts: 18
- Joined: Thu Apr 10, 2008 5:34 am
- Location: Manchester, NH
Re: How do I speed up a very slow listbox?
A ha! I solved my own problem! I had created a Winery subform on the Wine mainform to place the Winery listbox on. But a subform is not needed to link the Winery table to the Wine mainform. The listbox can be placed directly on the mainform. Then the listbox and its embedded SQL statement takes care of the linkage between the Wine and Winery tables. Now, it still takes about 8 seconds to open the form but it only takes about a second to navigate from one record to the next. (I think it would go even faster if it weren't for another two subforms on the Wine mainform, each with a Table Control for displaying the grapes and bottles associated with each wine.) This is sweet! It's simple and it's elegant. This listbox is turning out to be quite the useful little control. For those of you interested in the details:
The name of the mainform is frmWine. It is associated with the Wine table which has these columns:
If I specify "SQL" instead of "SQL [Native]" for the "Type of list contents", the form takes 35 seconds to load initially, but still navigates quickly through Wine records.
I'd still be interested to know if there is some way to speed up the initial loading of the listbox, but for now, this works well enough for me.
The name of the mainform is frmWine. It is associated with the Wine table which has these columns:
- WineID (int) - PK
WineryID (int) - FK
etc
- WineryID (int) - PK
Winery (tinytext) - INDEX of length 30 (I bet this does not need to be indexed)
etc
- Data field: WineryID
Type of list contents: SQL [Native]
List content: "SELECT Winery, WineryID FROM Winery ORDER BY Winery"
Bound field: 1
If I specify "SQL" instead of "SQL [Native]" for the "Type of list contents", the form takes 35 seconds to load initially, but still navigates quickly through Wine records.
I'd still be interested to know if there is some way to speed up the initial loading of the listbox, but for now, this works well enough for me.
JD
MySQL 5.0.45-community-nt, OOo 3.3.1, ODBC 5.1, Win XP Pro SP2.
MySQL 5.0.45-community-nt, OOo 3.3.1, ODBC 5.1, Win XP Pro SP2.
Re: How do I speed up a very slow listbox? [Solved]
Hm, did you check that out? I could not achieve such a behaviour before (see http://user.services.openoffice.org/en/ ... =39&t=5038, post from Apr 25th, 08:30 therein), and I just rechecked: The control properties revert always back to 1 if I set "bound field=0" for a listbox. It seems not possible to transfer the first field to the control's data field. Therefore the SQL statement has to contain at least two field names (which may be identical however), like(i.e., Bound field = 0 would have referred to the first column, Winery.)
Code: Select all
SELECT FIELD1, FIELD2 FROM SOMETABLE;
Code: Select all
SELECT FIELD1, FIELD1 FROM SOMETABLE;
-
- Posts: 18
- Joined: Thu Apr 10, 2008 5:34 am
- Location: Manchester, NH
Re: [Solved] How do I speed up a very slow listbox?
You are right, ufalke, if I set Bound field = 0, it reverts back to 1. However, as stated in OOo help on "Bound Fields":
Good catch. Thanks.
I checked that out and it works as advertised.If you delete the contents of the Bound field cell in the property browser, the first field of the result set is used to display and to exchange data.
Good catch. Thanks.
JD
MySQL 5.0.45-community-nt, OOo 3.3.1, ODBC 5.1, Win XP Pro SP2.
MySQL 5.0.45-community-nt, OOo 3.3.1, ODBC 5.1, Win XP Pro SP2.