PostgreSQL Interview Questions 2026

Published July 22, 2026 · Updated July 22, 2026

36 PostgreSQL interview questions from TCS, Razorpay, PhonePe, Stripe. All difficulty levels, all roles. Upvoted by engineers who were asked them.

36 questions
Companies: TCS, Razorpay, PhonePe, Stripe
1988 upvotes

PostgreSQL Questions by Company

TCS (2)

TCS Medium System Design round JavaSpring BootREST

Design a REST API for an e-commerce cart system. Define the endpoints (add item, remove item, get cart, checkout), explain authentication with JWT, handle race conditions on inventory, and discuss idempotency for the checkout endpoint.

↑ 46 upvotes · 47 engineers asked this · SDE2
TCS Medium Technical round MySQLPostgreSQL

Write a SQL query to find the second highest salary from an Employee table. Show at least two approaches: using LIMIT/OFFSET, using a subquery with MAX, and using DENSE_RANK(). Discuss which is most efficient and why.

↑ 55 upvotes · 58 engineers asked this · SDE2

Razorpay (5)

Razorpay Hard System Design round KafkaRedisPostgreSQL

Design Razorpay's payment retry system. When a payment fails due to a transient error (bank timeout, network blip), how do you retry safely without double-charging the customer? Cover: idempotency keys, exponential backoff with jitter, dead-letter queues, and reconciliation with bank statements.

↑ 72 upvotes · 71 engineers asked this · SDE2
Razorpay Hard System Design round KafkaPostgreSQLRedis

Design Razorpay's payout system (RazorpayX). Businesses send bulk payouts to thousands of vendor accounts simultaneously. Cover: batching, bank API rate limits, real-time status tracking, and failure handling.

↑ 61 upvotes · 39 engineers asked this · SDE2
Razorpay Hard Technical round PostgreSQLJavaKafka

How do you implement a distributed ledger for financial transactions? Explain double-entry bookkeeping in code, why you never update a balance directly, and how you use event sourcing to reconstruct the current balance from a transaction log.

↑ 56 upvotes · 35 engineers asked this · SDE2
Razorpay Hard System Design round KafkaRedisPostgreSQL

Design Razorpay's dashboard for merchants. A merchant wants to see real-time revenue, transaction success rates, and refund trends. How do you aggregate millions of transactions into live charts with under 5-second latency?

↑ 49 upvotes · 30 engineers asked this · SDE2
Razorpay Medium Technical round 3-6 yearsPostgreSQL

In PostgreSQL, what is the difference between SERIALIZABLE and READ COMMITTED isolation levels for a transaction that reads then updates an account balance?

↑ 20 upvotes · 9 engineers asked this · SDE2

PhonePe (3)

PhonePe Hard System Design round KafkaDistributed SystemsPostgreSQL

Design PhonePe's UPI transaction system to handle 1 billion transactions per day. Cover: request routing to the correct bank, NPCI integration, handling duplicate transactions, consistency vs availability trade-offs, and how you build a reliable audit trail for regulatory compliance.

↑ 89 upvotes · 89 engineers asked this · SDE2
PhonePe Hard Technical round PostgreSQLRedisJava

Explain how PhonePe handles transaction deduplication. A user taps "Pay" twice due to network lag. The same debit must not happen twice. Walk through idempotency at the API level, database level, and bank integration level.

↑ 55 upvotes · 35 engineers asked this · SDE2
PhonePe Hard System Design round KafkaPostgreSQLRedis

Design PhonePe's merchant settlement system. Thousands of merchants receive daily settlements of their collected payments minus fees. How do you compute net payables, batch into bank transfers, and provide a reconciliation report?

↑ 54 upvotes · 33 engineers asked this · SDE2

Stripe (5)

Stripe Hard System Design round KafkaPostgreSQLDistributed Systems

Design Stripe's webhook delivery system. Stripe sends millions of webhooks per day to customer endpoints that can be slow, down, or buggy. Cover: at-least-once delivery guarantees, retry with exponential backoff, ordering guarantees (or lack thereof), how to handle a customer endpoint that is down for 24h, and the dead-letter strategy.

↑ 79 upvotes · 77 engineers asked this · SDE2
Stripe Hard Technical round PostgreSQLRESTDistributed Systems

Explain how Stripe handles exactly-once payment processing. A customer clicks "Pay" twice in quick succession. How does Stripe prevent double-charging? Walk through idempotency keys in the API, database-level constraints, and how the client should handle the case where the first request times out.

↑ 67 upvotes · 65 engineers asked this · SDE2
Stripe Hard System Design round Distributed SystemsKafkaPostgreSQL

Design Stripe's fraud detection system. For every payment, you must decide accept/decline in under 100ms using hundreds of signals. Cover: feature engineering, real-time ML scoring, rule engine, and how you minimise false positives (declined legitimate payments).

↑ 68 upvotes · 44 engineers asked this · SDE2
Stripe Medium Technical round RESTPostgreSQLJava

Explain the difference between synchronous and asynchronous API design using Stripe as an example. When does a charge complete immediately vs require a webhook? How do you handle the intermediate "pending" state in your database?

↑ 57 upvotes · 36 engineers asked this · SDE1
Stripe Hard System Design round PostgreSQLKafkaDistributed Systems

Design Stripe's subscription billing system (Stripe Billing). Customers are charged on recurring intervals (monthly/annual) in different currencies, with proration for plan upgrades. Cover: invoice generation, dunning for failed payments, and SCA (Strong Customer Authentication) compliance.

↑ 63 upvotes · 40 engineers asked this · SDE2

Salesforce (2)

Salesforce Hard System Design round PostgreSQLDistributed SystemsAWS

Design a multi-tenant SaaS database architecture like Salesforce's. Thousands of enterprise customers share the same infrastructure but must never see each other's data. Compare silo (one DB per tenant), pool (shared DB, tenant_id column), and bridge models. Discuss query performance, schema customisation, and compliance isolation.

↑ 47 upvotes · 46 engineers asked this · SDE2
Salesforce Hard Technical round PostgreSQLJava

Explain Salesforce's metadata-driven architecture. Why does storing field definitions as data (instead of schema changes) enable the multi-tenant model? What are the trade-offs in query performance?

↑ 45 upvotes · 28 engineers asked this · SDE2

Oracle (5)

Oracle Medium Technical round PostgreSQLMySQL

Explain Oracle's MVCC (Multi-Version Concurrency Control) and how it enables consistent reads without blocking writers. How does it differ from SQL Server's locking approach? What are the downsides of MVCC (undo log growth, long-running transactions)?

↑ 88 upvotes · 33 engineers asked this · SDE2
Oracle Hard System Design round Distributed SystemsPostgreSQL

Design a distributed SQL database that supports ACID transactions across shards. Explain two-phase commit (2PC), its failure modes, and how Google Spanner uses TrueTime to replace 2PC with a more scalable approach.

↑ 41 upvotes · 39 engineers asked this · SDE2
Oracle Hard Technical round PostgreSQLMySQLJava

Explain Oracle's redo log and undo log. How do they work together to provide crash recovery and read consistency? Walk through what happens when a transaction commits, then the server crashes, then restarts.

↑ 51 upvotes · 31 engineers asked this · SDE2
Oracle Medium Technical round PostgreSQLMySQL

Write a SQL query to find the Nth highest salary from an Employee table without using LIMIT/TOP. Then solve it with a window function (DENSE_RANK) and explain which is more portable across Oracle, PostgreSQL, and MySQL.

↑ 63 upvotes · 42 engineers asked this · SDE1
Oracle Medium Technical round 3-6 yearsPostgreSQL

What is the difference between a PostgreSQL VIEW and a MATERIALIZED VIEW? When would a materialized view actually hurt you?

↑ 18 upvotes · 8 engineers asked this · Senior SDE

Airbnb (3)

Airbnb Hard System Design round ElasticsearchRedisDistributed Systems

Design Airbnb's search and availability system. A guest searches for "Paris, 3 nights, 2 guests" and sees ranked listings. Cover: availability calendar storage, real-time inventory updates (when host blocks dates), geospatial search, ranking signals (price, reviews, Superhost status), and how you handle the thundering herd on popular dates.

↑ 64 upvotes · 62 engineers asked this · SDE2
Airbnb Hard System Design round PostgreSQLKafkaRedis

Design Airbnb's review system. Guests and hosts review each other after a stay. Reviews are revealed simultaneously to prevent bias. Cover: the blind reveal mechanism, preventing fake reviews, and abuse detection.

↑ 55 upvotes · 34 engineers asked this · SDE2
Airbnb Hard System Design round Distributed SystemsKafkaPostgreSQL

Design Airbnb's host payout system. Hosts in 220+ countries receive payouts in local currency via bank transfer, PayPal, or Payoneer. Cover: currency conversion, scheduled payouts, failed payout handling, and tax compliance.

↑ 48 upvotes · 30 engineers asked this · SDE2

Flipkart (1)

Flipkart Hard Technical round JavaRedisPostgreSQL

Design a coupon/discount system for Flipkart Big Billion Days. The system must validate, apply, and prevent double-use of millions of coupons with high concurrency. Cover idempotency and distributed locking.

↑ 56 upvotes · 35 engineers asked this · SDE2

Swiggy (1)

Swiggy Medium Technical round PostgreSQLRedisJava

Design the data model for Swiggy's menu system. A restaurant has categories, items, add-ons, variants, and availability windows (breakfast/lunch/dinner). How do you model this in PostgreSQL and handle real-time menu updates?

↑ 48 upvotes · 28 engineers asked this · SDE2

Uber (1)

Uber Hard System Design round Distributed SystemsPostgreSQLKafka

Design Uber's payment reconciliation system. Uber collects payments in 70+ countries with different currencies, payment methods, and regulations. How do you reconcile driver payouts against rider charges and detect discrepancies?

↑ 60 upvotes · 38 engineers asked this · SDE2

Paytm (2)

Paytm Hard System Design round KafkaRedisPostgreSQL

Design Paytm's cashback system. When a user completes a transaction, they may receive cashback based on complex rules (merchant, time, amount, user segment). The cashback is credited to their wallet. Cover: rule engine, deduplication, and fraud prevention.

↑ 56 upvotes · 36 engineers asked this · SDE2
Paytm Hard System Design round AWSKafkaPostgreSQL

Design Paytm's KYC (Know Your Customer) pipeline. Users must submit Aadhaar/PAN documents for verification. How do you store documents securely (encrypted at rest), verify them (ML + manual review), and handle status callbacks?

↑ 49 upvotes · 30 engineers asked this · SDE2

Zomato (2)

Zomato Hard System Design round KafkaPostgreSQLRedis

Design Zomato Pro (subscription). Members get free delivery, discounts, and priority support. Cover: subscription lifecycle, prorated upgrades/downgrades, cohort-based analytics to measure retention, and how you handle payment failures.

↑ 50 upvotes · 31 engineers asked this · SDE2
Zomato Hard Technical round KafkaElasticsearchPostgreSQL

Explain Zomato's restaurant onboarding data pipeline. A new restaurant submits menus, photos, and operating hours. How do you validate, normalise, and make this data searchable within minutes of submission?

↑ 44 upvotes · 27 engineers asked this · SDE2

Adobe (1)

Adobe Hard System Design round AWSPostgreSQLKafka

Design Adobe Sign (e-signature platform). A contract is sent to 5 signatories who must sign in a specific order. Cover: document integrity (hash verification), audit trail, legal compliance (e-SIGN Act), and what happens if a signatory refuses.

↑ 54 upvotes · 33 engineers asked this · SDE2

Atlassian (3)

Atlassian Hard System Design round PostgreSQLAWSDistributed Systems

Design Confluence's page version history. Every edit creates a new version. Users can view any historical version and restore it. Cover: delta vs full-snapshot storage, efficient diff computation, and how you handle concurrent edits creating a branch.

↑ 56 upvotes · 35 engineers asked this · SDE2
Atlassian Hard Technical round JavaPostgreSQL

Explain how Jira's JQL (Jira Query Language) parser works. Walk through lexing, parsing, and AST generation. How do you translate a JQL query like "assignee = currentUser() AND status = Done" into an efficient SQL query?

↑ 44 upvotes · 26 engineers asked this · SDE2
Atlassian Hard System Design round Distributed SystemsPostgreSQLAWS

Design Bitbucket's code review system (Pull Requests). Multiple reviewers comment on specific lines of code. The PR is mergeable when all reviewers approve. Cover: diff computation, inline comments anchored to code lines, and what happens when new commits invalidate existing comments.

↑ 60 upvotes · 37 engineers asked this · SDE2

Practice these questions with AI feedback

Get instant grading on your answers, identify your weak areas, and generate a personalised 14-day study plan — all free.

Build my study plan →

PostgreSQL questions at each company

Razorpay PostgreSQL Stripe PostgreSQL Oracle PostgreSQL

Frequently asked questions

Design a REST API for an e-commerce cart system. Define the endpoints (add item, remove item, get cart, checkout), explain authentication with JWT, handle race conditions on inventory, and discuss idempotency for the checkout endpoint.
Design a REST API for an e-commerce cart system. Define the endpoints (add item, remove item, get cart, checkout), explain authentication with JWT, handle race conditions on inventory, and discuss idempotency for the checkout endpoint.
Write a SQL query to find the second highest salary from an Employee table. Show at least two approaches: using LIMIT/OFFSET, using a subquery with MAX, and using DENSE_RANK(). Discuss which is most efficient and why.
Write a SQL query to find the second highest salary from an Employee table. Show at least two approaches: using LIMIT/OFFSET, using a subquery with MAX, and using DENSE_RANK(). Discuss which is most efficient and why.
Design Razorpay's payment retry system.
Design Razorpay's payment retry system. When a payment fails due to a transient error (bank timeout, network blip), how do you retry safely without double-charging the customer? Cover: idempotency keys, exponential backoff with jitter, dead-letter queues, and reconciliation with bank statements.
Design PhonePe's UPI transaction system to handle 1 billion transactions per day.
Design PhonePe's UPI transaction system to handle 1 billion transactions per day. Cover: request routing to the correct bank, NPCI integration, handling duplicate transactions, consistency vs availability trade-offs, and how you build a reliable audit trail for regulatory compliance.
Design Stripe's webhook delivery system.
Design Stripe's webhook delivery system. Stripe sends millions of webhooks per day to customer endpoints that can be slow, down, or buggy. Cover: at-least-once delivery guarantees, retry with exponential backoff, ordering guarantees (or lack thereof), how to handle a customer endpoint that is down for 24h, and the dead-letter strategy.