Write PostgreSQL updates with date filters
CircleSoftware Engineer · Online AssessmentLast updated
This question evaluates competency in PostgreSQL data manipulation, covering updates with correct timestamp handling, upserts with conflict resolution, date-range selection using timestamptz, and index design plus performance analysis with EXPLAIN ANALYZE.
Write PostgreSQL statements to: (
- update a flight's price and set updated_at correctly; (
- upsert a booking record with conflict handling; (
- select bookings filtered by a UTC date range using timestamptz without off-by-one errors; (
- add appropriate indexes and demonstrate their use with EXPLAIN ANALYZE. Discuss common pitfalls when moving from generic SQL to PostgreSQL, including date/time casting, time zones, text vs citext, and use of immutable/stable functions in indexes.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.