One of the most celebrated results for evaluating conjunctive queries (CQs) is the Yannakakis algorithm [24] proposed in 1981. It is known that free-connex CQs can be evaluated in O(N + OUT) time, where N is the input size of the database and OUT is the output size of the query result. This is already output-optimal. However, only an upper bound O(N & centerdot; OUT) on the runtime is known for the remaining acyclic but non-freeconnex CQs. Alternatively, one can convert a non-freeconnex CQ into a free-connex one using tree decomposition techniques, and then run the Yannakakis algorithm. However, none of them is known to be output-optimal. In this work, we show a lower and upper bound matching Theta (N & centerdot; OUT1-1/fn-fhtw +OUT) for computing acyclic CQs, where fn-fhtw is the free-connex fractional hyper-tree width of the query. Although free-connex fractional hypertree width is a natural and well-established measure of how far a CQ is from being free-connex, we demonstrate that it precisely captures the output-optimal complexity of acyclic CQs. To our knowledge, this has been the first polynomial improvement over the Yannakakis algorithm in the last 40 years and completely resolves the open question of computing acyclic CQs in an output-optimal way. Our output-optimal algorithm proposed for acyclic CQs also extends to cyclic CQs, as well as CQs with aggregations over arbitrary commutative semirings.