Association and Filtering

Hopefully a quick one :

I have a products table and in the view I am showing these products as
well as a sidebar to “filter” the products by team, size, color etc
(which are all attributes of other join tables). What is the most
efficient (in terms of best practice) way of getting the filtered list
in the sidebar? I want to minimise the hits on the database. Is it
possible to just grab the products and then just show the distinct
“teams” for example (considering the join association would have
already grabbed the team name)?