New query taking over 60% of running time
The expression where DATE_PART('day', now() - fecha ) &lt; 5 can not make use of an index on the column fecha. 

Rewrite the expression so that it can use an index:

where fecha &gt; current_date - 5