JDBC Batching, Connection Pooling and SQL Logging
Learn JDBC Batching, Connection Pooling and SQL Logging (Phase 7 · Hibernate Performance Optimization (Essential), Hibernate) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
JDBC batching • By default every INSERT/UPDATE/DELETE is a separate round trip. JDBC batching groups statements into batches: hibernate.jdbc.batch_size=50 . It works for writes only and requires: a generator that does not force immediate execution ( SEQUENCE , not IDENTITY ), hibernate.order_inserts=true and hibernate.order_updates=true (so same-table statements are adjacent), hibernate.jdbc.batch_versioned_data=true . • Driver flags: MySQL rewriteBatchedStatements=true ; PostgreSQL reWriteBatchedInserts=true . • Process large imports in chunks with flush() + clear() every batch size; consider...