Good luck debugging! Seriously. You can't attach a debugger to your DB.
https://dbeaver.com/docs/wiki/PGDebugger/
https://www2.navicat.com/manual/online_manual/en/navicat/mac...
https://www.cybertec-postgresql.com/en/debugging-pl-pgsql-ge...
Other platforms have options as well:
https://docs.microsoft.com/en-us/sql/ssms/scripting/transact...
Of course, many programming languages also do not have a debugging quality-of-life compared to Visual Studio.
You certainly can and do add logging, this can be useful.
One exception is having access to that data because I was working ON the prod server. Read that again. It was deeply uncomfortable to work like this. Very worrying every day.
Better I can even optimize to native code, and still debug them.