Jacob Costello <jake@xxxxxxxxxxxxxxxxx> writes: > Postgres doesn't seem to optimize away unnecessary joins There is no such thing as an unnecessary join, unless you are willing to stake the correctness of the query on constraints that could be dropped after the query is planned. Until we have some infrastructure to deal with that situation, nothing like this is going to happen. regards, tom lane