I recently found that writing clever sql queries can be problematic too. Six hours to debug the issue after writing it some 6-7 years ago...