Top 10 PostgreSQL Interview Questions Every Fresher Should Know

Top 10 PostgreSQL Interview Questions Every Fresher Should Know Work through these 10 questions out loud. Open any question for the full model answer, the trap to avoid, and the follow-up a panel usually asks.

  1. Database sharding strategies for high-scale Java services?

    Shard by tenant_id mod 32 — RoutingDataSource lookup. User-scoped queries single shard. Global admin reports from CQRS read replica or Elasticsearch. Plan shard key early —...

    Full answer

  2. What is the difference between ArrayList and LinkedList?

    ArrayList: dynamic array, great for get(i) and iteration, amortized append. LinkedList: node chain, costly random access, only wins for frequent insert/remove in middle with...

    Full answer

  3. What are text blocks and how do they improve Java code?

    String query = """ SELECT u.id, u.name FROM users u WHERE u.active = true """; — readable without \n concatenation. Use formatted for parameters carefully — prefer...

    Full answer

  4. Best practices for Spring Data pagination with Pageable?

    Controller: @PageableDefault(size=20, sort="createdAt", direction=DESC) Pageable p. Cap size at 100. Admin reports: keyset pagination on id > lastId for deep pages — OFFSET...

    Full answer

  5. How does @Transactional work?

    Spring creates a proxy around @Transactional beans. Calling createOrder() from another bean starts a transaction on the thread-bound EntityManager; commit on success, rollback...

    Full answer

  6. How do you test Spring Boot applications?

    Unit test services with Mockito — no Spring. @WebMvcTest + MockMvc for controller contract. @DataJpaTest for repository queries. @SpringBootTest + Testcontainers for critical...

    Full answer

  7. How do Spring application events work with @EventListener?

    OrderService publishes OrderCreatedEvent after save. EmailListener @EventListener sends confirmation. @TransactionalEventListener(AFTER_COMMIT) prevents email on rolled-back...

    Full answer

  8. When use @Query native SQL vs JPQL in Spring Data JPA?

    JPQL for standard entity fetches and portable logic. Native for PostgreSQL-specific jsonb queries, recursive CTEs, or performance-tuned index hints after EXPLAIN. Interface...

    Full answer

  9. How do Flyway/Liquibase integrate with Spring Boot JPA?

    Prod: spring.jpa.hibernate.ddl-auto=validate, Flyway V1__init.sql through Vn. CI: @Testcontainers PostgreSQL + Flyway migrate + integration tests. Never rename column without...

    Full answer

  10. A REST API is slow only in production, not locally. How do you debug it?

    Enable Micrometer timers and Hibernate statistics or datasource-proxy in staging with prod-like data. Check Hikari `connections-active`, JVM GC pauses, and Feign/RestClient...

    Full answer

PostgreSQL Interview Questions and Answers · Top 50 PostgreSQL Interview Questions and Answers (2026 Edition) · Top 40 PostgreSQL Interview Questions | Must-Prepare before interview. · PostgreSQL Interview Questions Every Fresher Must Know

All interview question lists · Interview guides · Home · Support the platform