LibreOffice base is slow in sql statements

Kubuntu 16.10

I have a form with controls that I used for some years without problems. In this form I use BASIC to update the sql selector of four controls when navigating in the form. The refresh speed was less than 1 sec (not really noticeable) when changing record. After update to SQL became very slow. Updating theses four controls take at least 3 seconds often more (typical 6).

SQL is “select name2 from T2 where id2 in (select id_r2 from TR12 where id_r1 = id1)”

T1 is the table related to the form, id1 the id of the present record.
T2 is a table with name2 and id2 (30 records)
TR12 relate T1 and T2 in a many to many relation (id_r1, id_r2) (30000 records)

SQL is slow, taking 3 to 4 seconds to execute for the control where T2 is 30000 records. The delay is related on the number of records in TR12

I have try to change for “select name from T2, TR12 where id2 = id_r2 and id_r1 = id1” but it’s worse. LibreOffice freeze for a long time.

The form is slow only in operation related to SQL, GUI and Basic operate at normal speed.

Any suggestions ?

I have do a small experience :

Kubuntu 16.10 + Libre Office + computer with i7, 12 Gb memory, only libreoffice running. : 8 sec. passing from a record to the next…

Kubuntu 15.10 + LibreOffice + VIRTUAL MACHINE, 1 processor, 2 Gb memory : impossible to measure time passing from a record to the next. To fast.

Libre was running with the same correct speed on Kubuntu 16.04 (on this same machine).

Same data in the all case. Same physical machine.

I have noticed that Libre was using Java 1.7.0_101. So I have installed this java on Libre without any difference.

Is there a bug in HSQLBD ?