| View previous topic :: View next topic |
| Author |
Message |
Mobidoy General User

Joined: 15 Dec 2010 Posts: 19 Location: Canada
|
Posted: Sat Jan 22, 2011 3:46 pm Post subject: [SOLVED] Slow Database tried fixes but, no help 3.3 RC 10 |
|
|
I have a database with a table that has over 6000 entries. when I do a search, the first time, it takes about 5 minutes for it to get to the end. Once that is done, the database is lightning fast.
I have tried checkpoint defrag, the database is embedded HSQL but, when I do this, on next reboot, it will crash so I have to delete the .openoffice directory in my home.
What should I do/try out ?
Last edited by Mobidoy on Thu Jan 27, 2011 9:36 am; edited 2 times in total |
|
| Back to top |
|
 |
Sliderule Super User


Joined: 29 May 2004 Posts: 2473 Location: 3rd Rock From The Sun
|
Posted: Sat Jan 22, 2011 4:02 pm Post subject: |
|
|
Permission to ask . . . on the field(s) that you are doing your search . . . is there an INDEX on the field(s)?
If not, you might want to create an index on the field(s) and see if that helps.
Also, what might be helpful for me is if you could post here the SQL you are using in the search . . . if you created the Query with the GUI ( Graphic User Interface ) . . . you can press on the Switch Design View On/Off icon on the toolbar.
I hope this helps, please be sure to let me / us know.
Sliderule
Thanks to add [Solved] in your first post Title ( edit button ) if your issue has been fixed / resolved. |
|
| Back to top |
|
 |
Mobidoy General User

Joined: 15 Dec 2010 Posts: 19 Location: Canada
|
Posted: Sat Jan 22, 2011 5:14 pm Post subject: |
|
|
How can I tell if there is an Index ?
and here is the query:
| Code: | | SELECT "pieces"."Numéro_de_pièce" AS "Numéro de pièce", "pieces"."Description_Anglais" AS "Description", "pieces"."Description_Français" AS "Description", "piecesfabricant"."Fabricant_1" AS "Fabricant", "piecesfabricant"."Numéro_Fabricant_1" AS "Numéro", "piecesfabricant"."Fabricant_2" AS "Fabricant", "piecesfabricant"."Numéro_Fabricant_2" AS "Numéro", "piecesfabricant"."Fabricant_3" AS "Fabricant", "piecesfabricant"."Numéro_Fabricant_3" AS "Numéro", "piecesfabricant"."Fabricant_4" AS "Fabricant", "piecesfabricant"."Numéro_Fabricant_4" AS "Numéro" FROM "piecesfabricant", "pieces" WHERE "piecesfabricant"."Numéro_de_pièce" = "pieces"."Numéro_de_pièce" |
|
|
| Back to top |
|
 |
Sliderule Super User


Joined: 29 May 2004 Posts: 2473 Location: 3rd Rock From The Sun
|
Posted: Sat Jan 22, 2011 5:36 pm Post subject: |
|
|
Mobidoy:
You wrote / asked:
| Mobidoy wrote: | | How can I tell if there is an Index ? |
To 'see' and if necessary, create an additional index ( or indices as the case may be ) . . . click on Tables under Database
If you right click on your table and select Edit from the drop down menu . . . and . . . click on Index Design on the Toolbar. You can now 'see' the field(s) that are in the Index for each of your two tables in question:
- "piecesfabricant"
- "pieces"
Now, this is your SQL . . . I just added some line feeds for readability:
| Code: | SELECT
"pieces"."Numéro_de_pièce" AS "Numéro de pièce",
"pieces"."Description_Anglais" AS "Description",
"pieces"."Description_Français" AS "Description",
"piecesfabricant"."Fabricant_1" AS "Fabricant",
"piecesfabricant"."Numéro_Fabricant_1" AS "Numéro",
"piecesfabricant"."Fabricant_2" AS "Fabricant",
"piecesfabricant"."Numéro_Fabricant_2" AS "Numéro",
"piecesfabricant"."Fabricant_3" AS "Fabricant",
"piecesfabricant"."Numéro_Fabricant_3" AS "Numéro",
"piecesfabricant"."Fabricant_4" AS "Fabricant",
"piecesfabricant"."Numéro_Fabricant_4" AS "Numéro"
FROM "piecesfabricant",
"pieces"
WHERE "piecesfabricant"."Numéro_de_pièce" = "pieces"."Numéro_de_pièce" |
Since, the most important part for matching the two table is . . .
| Code: | | WHERE "piecesfabricant"."Numéro_de_pièce" = "pieces"."Numéro_de_pièce" |
the thing is . . . those TWO fields
- "piecesfabricant"."Numéro_de_pièce"
- "pieces"."Numéro_de_pièce"
should EACH be the first part of an index . . . first part meaning the first field in the index . . . so . . . the database does NOT have to create a new index each time.
If necessary, with the Indexes pop-up, you can click on the icon . . . New Index . . . and . . . create an index on the appropriate field(s).
This way, like looking in a phone book, the database will have a way to get to the needed records quickly rather than reading the entire phone book to find the matches.
I hope this helps, please be sure to let me / us know.
Sliderule
Thanks to add [Solved] in your first post Title ( edit button ) if your issue has been fixed / resolved. |
|
| Back to top |
|
 |
Mobidoy General User

Joined: 15 Dec 2010 Posts: 19 Location: Canada
|
Posted: Sat Jan 22, 2011 6:14 pm Post subject: |
|
|
I do indeed have an index in each db for the two fields
1. "piecesfabricant"."Numéro_de_pièce"
2. "pieces"."Numéro_de_pièce"
but, I have also noticed that there is a second index in
"piecesfabricant"."Numéro_de_pièce"
first which is unique and second is not... Is the second needed and could it be part of the slowdown ? |
|
| Back to top |
|
 |
Sliderule Super User


Joined: 29 May 2004 Posts: 2473 Location: 3rd Rock From The Sun
|
Posted: Sat Jan 22, 2011 6:37 pm Post subject: |
|
|
Mobidoy:
You said / asked:
| Mobidoy wrote: | | Is the second needed and could it be part of the slowdown ? |
Needed, probably not. Part of the slowdown . . . probably since the database engine does not know which of the duplicate indices to use. Remember, the file MUST contain a PRIMARY KEY ( that means the data that makes each record unique ). You should NOT delete a Primary Key index and end up with NO Primary Key.
If it were me . . . I would CLOSE the database file ( *.odb ) . . . make a backup of the file ( always want to be safe rather than sorry ) and open the file, delete one of the indices and see if that helps.
Also, please, after performing the above steps, to SHRINK the size of the database file ( *.odb ) . . . if you have been doing alot of database changes ( such as UPDATES, ALTER -- changing table design, DELETES etc ) . . . from the Menu:
Tools -> SQL...
- enter in the Command to execute box:
Press the Execute button
Command successfully executed. should be displayed by the database engine.
Press the Close button
According to HSQl documentation found at:
http://www.hsqldb.org/doc/guide/ch09.html#checkpoint-section
| HSQL Documentation: http://www.hsqldb.org/doc/guide/ch09.html#checkpoint-section wrote: |
CHECKPOINT
CHECKPOINT [DEFRAG];
Closes the database files, rewrites the script file, deletes the log file and opens the database.
If DEFRAG is specified, this command also shrinks the .data file to its minimal size. |
I hope this helps, please be sure to let me / us know.
Sliderule
Thanks to add [Solved] in your first post Title ( edit button ) if your issue has been fixed / resolved. |
|
| Back to top |
|
 |
Mobidoy General User

Joined: 15 Dec 2010 Posts: 19 Location: Canada
|
Posted: Sat Jan 22, 2011 7:08 pm Post subject: |
|
|
First thing I tried was to delete the extra index, which is not unique but, I get an error message:
| Quote: | SQL Status: S0011
Error code: -50
Attempt to drop a foreign key index: SYS_IDX_120 in statement [DROP INDEX "SYS_IDX_120" ON "piecesfabricant"] |
What is this ? |
|
| Back to top |
|
 |
Sliderule Super User


Joined: 29 May 2004 Posts: 2473 Location: 3rd Rock From The Sun
|
Posted: Sat Jan 22, 2011 7:15 pm Post subject: |
|
|
OK, you must have created a RELATIONSHIP between the two tables.
You can confirm this from the Menu:
Tools -> Relationships...
and, it ( the foreign key ) refers to the FOREIGN KEY INDEX ( relation between the two tables ), you do NOT want to change / drop it.
At this point, please try what the I identified above . . .
to shink the file size ( OpenOffice Base file *.odb ), if possible. If so, the 'uncompressing' in the background of the *.odb file when opened, might be alot quicker, and, take / need less internal computer memory.
Sliderule
Thanks to add [Solved] in your first post Title ( edit button ) if your issue has been fixed / resolved. |
|
| Back to top |
|
 |
Mobidoy General User

Joined: 15 Dec 2010 Posts: 19 Location: Canada
|
Posted: Sat Jan 22, 2011 7:31 pm Post subject: |
|
|
I do have a relationship so, I wont touch it.
I have done the
but sadly, it is still slow. This is a new database created with data that was in calc spreadsheet, created from old Dbase db files. If it can help....
I have created the tables first, set the primary keys then, imported the data. |
|
| Back to top |
|
 |
Sliderule Super User


Joined: 29 May 2004 Posts: 2473 Location: 3rd Rock From The Sun
|
Posted: Sat Jan 22, 2011 7:40 pm Post subject: |
|
|
OK, one more question . . . if you go to EDIT your table ( right click on the Table, select Edit from the drop down menu ) . . . I want to know how the TEXT fields are defined.
That is, are they defined as:
- CHAR
- VARCHAR
- VARCHAR_IGNORECASE
AND what is the LENGTH of the two fields:
- piecesfabricant"."Numéro_de_pièce"
- "pieces"."Numéro_de_pièce"
I am asking because I wonder if you defined these as CHAR and they and the indices are taking up alot more space than needed, compared to if they had been defined with VARCHAR_IGNORECASE, or VARCHAR ( I recommend the former rather than the later ) if it might help to change the field definition.
Sliderule
Thanks to add [Solved] in your first post Title ( edit button ) if your issue has been fixed / resolved. |
|
| Back to top |
|
 |
Mobidoy General User

Joined: 15 Dec 2010 Posts: 19 Location: Canada
|
Posted: Sat Jan 22, 2011 7:56 pm Post subject: |
|
|
In fact, they are both integer length 10 ... Should I change them varchar_ignorecase ?
It does not need to be Integer even thougth it is "part Number" (in french).
| sliderule wrote: | OK, one more question . . . if you go to EDIT your table ( right click on the Table, select Edit from the drop down menu ) . . . I want to know how the TEXT fields are defined.
That is, are they defined as:
- CHAR
- VARCHAR
- VARCHAR_IGNORECASE
AND what is the LENGTH of the two fields:
- piecesfabricant"."Numéro_de_pièce"
- "pieces"."Numéro_de_pièce"
I am asking because I wonder if you defined these as CHAR and they and the indices are taking up alot more space than needed, compared to if they had been defined with VARCHAR_IGNORECASE, or VARCHAR ( I recommend the former rather than the later ) if it might help to change the field definition.
Sliderule
Thanks to add [Solved] in your first post Title ( edit button ) if your issue has been fixed / resolved. |
|
|
| Back to top |
|
 |
Sliderule Super User


Joined: 29 May 2004 Posts: 2473 Location: 3rd Rock From The Sun
|
Posted: Sat Jan 22, 2011 8:04 pm Post subject: |
|
|
I see, they are INTEGER 10.
No, in that case, I would keep them that way. Sorry, I was thinking they might look like ( for example ): 103-30407
or something ( characters not ONLY numbers ).
The only other suggestion I can thnk of, is to upgrade to HSQL 2.0.1 . . . a much more efficent database engine that makes better use of indices in Queries.
Posts by dacm on this web site, AND, at:
http://user.services.openoffice.org/en/forum/
describe the technique to do this.
Sliderule
Thanks to add [Solved] in your first post Title ( edit button ) if your issue has been fixed / resolved. |
|
| Back to top |
|
 |
Mobidoy General User

Joined: 15 Dec 2010 Posts: 19 Location: Canada
|
Posted: Sat Jan 22, 2011 9:43 pm Post subject: |
|
|
| I am still trying to figure out how to do the upgrade under Ubuntu 10.10 64bits, will let you know as soon as I am done. |
|
| Back to top |
|
 |
Mobidoy General User

Joined: 15 Dec 2010 Posts: 19 Location: Canada
|
|
| Back to top |
|
 |
Sliderule Super User


Joined: 29 May 2004 Posts: 2473 Location: 3rd Rock From The Sun
|
Posted: Sat Jan 22, 2011 10:25 pm Post subject: |
|
|
Ok, so, it was an Operating System issue, NOT an OpenOffice Base issue. Fine.
You said / asked"
| Mobidoy wrote: | but I would like to follow the 2.0.1 upgrade with multi mode as this DB, once over, will be share by about 10 users.
I just cant figure out how to do this under Ubuntu 10.10 64 bits. Can you help ? |
dacm is very helpful, and, perhaps he or others here can help you. It should NOT be much different between operating systems.
Since you are going to run the database as a server ( with 10 users ) that means you will have to have the HSQL database running in the background on a server ( so others can connect to it ). Each OpenOffice Base file will contain:
- Queries
- Forms
- Reports
But the database part, will reside in three separte files on the 'server' These files:
- *.properties
- *.script
- *.data
can be taken from your CURRENT OpenOffice Base file that is compressed ( zipped ) so you have the database definitions and data. This is where dacm can help.
Sliderule |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|