I guess writing things out already helps a lot;
I figured that the having() clause must cause the slowness, and there is another way of writing the same:
select btw_omschrijving, sum(boe_prijs_netto / btw_percentage) /100.0, sum(boe_prijs_netto / btw_percentage * (btw_percentage - 1) )/100.0, sum(boe_prijs_netto) /100.0
from tblbtw left join tblartikel on art_btw_id = btw_id left join tblartikelinstance on ari_art_id = art_id left join tblartikelverhuur on avh_ari_id = ari_id left join tblboeking on (boe_avh_id = avh_id or boe_art_id = art_id) and boe_zle_id = 107
where boe_prijs_netto is not null
group by btw_id;
This is already a bit faster, but still too slow for my actual purpose;
the speed is now 0.50 sec. (a 4 time improvement already).
Can I get this down to <.10 sec?
Eljakim