Use pg_sleep in Postgres to simulate a slow query

select pg_sleep(n) sleeps for n seconds in Postgres.

Source: https://www.endpoint.com/blog/2012/11/05/how-to-make-postgresql-query-slow