title: How to speed up sql queries ? Indexes?
body: <p>I have the following database structure :</p>
  <pre><code>create table Accounting
  (
    Channel,
    Account
  )
  
  create table ChannelMapper
  (
    AccountingChannel,
    ShipmentsMarketPlace,
    ShipmentsChannel
  )
  
  create table AccountMapper
  (
    AccountingAccount,
    ShipmentsComponent
  )
  
  create table Shipments
  (
     MarketPlace,
     Component,
     ProductGroup,
     ShipmentChannel,
     Amount
   )
  </code></pre>
  <p>I have the following query running on these tables and I'm trying to optimize the query to run as fast as possible :</p>
  <pre><code> select Accounting.Channel, Accounting.Account, Shipments.MarketPlace
   from Accounting join ChannelMapper on Accounting.Channel = ChannelMapper.AccountingChannel
  
   join AccountMapper on Accounting.Accounting = ChannelMapper.AccountingAccount
   join Shipments on 
   (
       ChannelMapper.ShipmentsMarketPlace = Shipments.MarketPlace
       and ChannelMapper.AccountingChannel = Shipments.ShipmentChannel
       and AccountMapper.ShipmentsComponent = Shipments.Component
   )
   join (select Component, sum(amount) from Shipment group by component) as Totals
      on  Shipment.Component = Totals.Component
  </code></pre>
  <p>How do I make this query run as fast as possible ? Should I use indexes ? If so, which columns of which tables should I index ?</p>
  <p>Here is a picture of my query plan :</p>
  <p><img src="https://i.stack.imgur.com/MZTxB.jpg" alt="enter image description here" /></p>
  <p>Thanks,</p>