How to avoid unnecessary join

Hi, I have an explore in which I join a view, say view1 to another view, say view2 like so:

explore: view1{

  join : view2{
    type: inner
    relationship: many_to_many
    sql_on: ${view1.id} = ${view2.id} ;;
  }
}

Now, when I am in Explore, both view1 and view2 are visible to explore. If I select dimensions and measures only from view1, then the sql generated has no joins which is what I expected. But, if I select dimensions and measures only from view2, the sql generated has a join. I was expecting that since no measure and dimension has been selected from view1 there would have been no join in the resulting sql. Why is a join required when nothing from view1 has been selected, is there a reason looker does this? And are there ways I can define the lookMl to avoid this join?

Thanks for the inputs

Solved Solved
2 12 3,303
1 ACCEPTED SOLUTION

It makes sense to me but maybe just cos I have never had your use case. An explore is usually centred around 1 thing, eg. users, orders, dates…..so having this at the centre is all good.

Also as soon as you add more views you will need to have an order of how these views are joined in otherwise it will start getting complicated. eg. x joins to y unless y not there so it joins to z on different fields.

View solution in original post

12 REPLIES 12
Top Labels in this Space
Top Solution Authors