postgresql datetrunc too slow

Solutions on MaxInterview for postgresql datetrunc too slow by the best coders in the world