rdnews(at)dahlsys(dot)com (Roger Dahl) writes:
> select b.name,
> from boxes b
> inner join item_box_maps m on m.box_id = b.id
> inner join items i on m.id = m.item_id
> where i.name = 'hammer';
You didn't say which PG version you are running, but I bet it is one
that strictly follows the JOIN syntax order. Try flipping the order of
the JOIN clauses:
select b.name,
from boxes b
inner join items i on m.id = m.item_id
inner join item_box_maps m on m.box_id = b.id
where i.name = 'hammer';
There is more about this in the Performance Tips section of the docs.
regards, tom lane