How to speed up sql queries ? Indexes?

前端 未结 3 1341
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 15:02

I have the following database structure :

create table Accounting
(
  Channel,
  Account
)

create table ChannelMapper
(
  AccountingChannel,
  ShipmentsMark         


        
3条回答
  •  無奈伤痛
    2020-12-01 15:19

    The other three answers seem to have indexes covered so this is in addition to indexes. You have no where clause which means you are always selecting the whole darn database. In fact, your database design doesn't have anything useful in this regard, such as a shipping date. Think about that.

    You also have this:

    join (select Component, sum(amount) from Shipment group by component) as Totals
    on  Shipment.Component = Totals.Component
    

    That's all well and good but you don't select anything from this subquery. Therefore why do you have it? If you did want to select something, such as the sum(amount), you will have to give that an alias to make it available in the select clause.

提交回复
热议问题