It has been a while since my sql days thus I am wondering whether it is possible to further optimize the following query? The goal is to collect all accounts for each accountant including all the bookings and movements associated with it. Performance/query-time is very important since there are '3 digit'-million datasets...
select Accountant.person_id,
Account.account_id,
Account.number,
Account.balance,
Account_Type.type_number,
Booking.booking_id,
Booking.amount,
Movement.movement_date,
Movement.movement_desc
from Accountant
join Account on Accountant.person_id = Account.person_id
join Account_Type on Account.account_type_id = Account_Type.account_type_id
left outer join Booking on Account.account_id = Booking.account_id
left outer join Movement on Booking.movement_id = Movement.movement_id;
The entity model looks something like that:

UPDATE: Since some of you are wondering: Yes I am simply selecting hundreds of million of rows since the query is used to migrate data. The data queried is used to construct a new data structure which is put in another database...
- To allow returning accounts with no Bookings I added the outer joins. Is that the right syntax?
- Here is the explain plan - seeing any optimization possibilities?

- After adding some missing indices the query takes (in an external tool) about 1/2 hour. In java a memory error is thrown at some point. Any hints (except increasing memory) how to optimize that?
JOIN?bookingisn't linked toaccountin yourwhereclause. Your diagram shows four relationships, so only having three in thewhereclause is a bit of a red flag. It would be much more obvious with ANSI joins. (With no actual filters, just join conditions, hopefully you're expecting a large result set; sounds like you expect all data from all five tables; not sure how useful that is!)