MQTT & POSTGRESQL on Raspberry

Please see the link below on how to share a flow here so that it is importable. You can edit your previous post accordingly.
Do you have a particular reason for wanting to use postgresql? You might like to consider influxdb which is designed for exactly the requirement you describe. There are influx nodes that make it very easy to output to influx (node-red-contrib-influxdb) and grafana has built in support for influx.