Two queries run much longer when combined into one The first two queries below are very similar. The third is practically the union of the first two:

sql&gt; SELECT sigla_partido, SUM(receita_valor) 
     FROM prestacao_conta_eleicao_candidato_2014
     NATURAL JOIN prestacao_conta_eleicao_candidato_2014_receita
     GROUP BY sigla_partido

[2016-03-07 22:54:55] 32 row(s) retrieved starting from 1 in 352ms (439ms total)

sql&gt; SELECT sigla_partido, SUM(despesa_valor) 
     FROM prestacao_conta_eleicao_candidato_2014
     NATURAL JOIN prestacao_conta_eleicao_candidato_2014_despesas
     GROUP BY sigla_partido

[2016-03-07 22:54:59] 32 row(s) retrieved starting from 1 in 1s 648ms (1s 832ms total)

sql&gt; SELECT sigla_partido, SUM(receita_valor), SUM(despesa_valor) 
     FROM prestacao_conta_eleicao_candidato_2014
     NATURAL JOIN prestacao_conta_eleicao_candidato_2014_receita
     NATURAL JOIN prestacao_conta_eleicao_candidato_2014_despesas
     GROUP BY sigla_partido

[2016-03-07 22:55:30] 32 row(s) retrieved starting from 1 in 18s 264ms (29s 932ms total)


I expected the runtime of the third query to be close to the sum of the execution times of the first two queries. That did not happen and the third query took much longer than expected. For what reason?
You better combine those queries using Derived Tables;

select sigla_partido, receita_valor, despesa_valor
from
 (
     SELECT sigla_partido, SUM(receita_valor) as receita_valor
     FROM prestacao_conta_eleicao_candidato_2014
     NATURAL JOIN prestacao_conta_eleicao_candidato_2014_receita
     GROUP BY sigla_partido
  ) as receita
natural join 
 (
     SELECT sigla_partido, SUM(despesa_valor) as despesa_valor
     FROM prestacao_conta_eleicao_candidato_2014
     NATURAL JOIN prestacao_conta_eleicao_candidato_2014_despesas
     GROUP BY sigla_partido
 ) as despesas


Btw, check if the slow query actually returned the correct result.