SlideShare uma empresa Scribd logo
1 de 61
© 2016 NetCracker Technology Corporation Confidential
PostgreSQL and JDBC: striving for top performance
Vladimir Sitnikov
PgConf 2016
2© 2016 NetCracker Technology Corporation Confidential
About me
‱ Vladimir Sitnikov, @VladimirSitnikv
‱ Performance architect at NetCracker
‱ 10 years of experience with Java/SQL
‱ PgJDBC committer
3© 2016 NetCracker Technology Corporation Confidential
Explain (analyze, buffers) PostgreSQL and JDBC
‱Data fetch
‱Data upload
‱Performance
‱Pitfalls
4© 2016 NetCracker Technology Corporation Confidential
Intro
Fetch of a single row via primary key lookup takes
20ms. Localhost. Database is fully cached
A. Just fine C. Kidding? Aim is 1ms!
B. It should be 1sec D. 100us
5© 2016 NetCracker Technology Corporation Confidential
Lots of small queries is a problem
Suppose a single query takes 10ms, then 100 of
them would take a whole second *
* Your Captain
6© 2016 NetCracker Technology Corporation Confidential
PostgreSQL frontend-backend protocol
‱Simple query
‱ 'Q' + length + query_text
‱Extended query
‱Parse, Bind, Execute commands
7© 2016 NetCracker Technology Corporation Confidential
PostgreSQL frontend-backend protocol
Super extended query
https://github.com/pgjdbc/pgjdbc/pull/478
backend protocol wanted features
8© 2016 NetCracker Technology Corporation Confidential
PostgreSQL frontend-backend protocol
Simple query
‱Works well for one-time queries
‱Does not support binary transfer
9© 2016 NetCracker Technology Corporation Confidential
PostgreSQL frontend-backend protocol
Extended query
‱Eliminates planning time
‱Supports binary transfer
10© 2016 NetCracker Technology Corporation Confidential
PreparedStatement
Connection con = ...;
PreparedStatement ps =
con.prepareStatement("SELECT...");
...
ps.close();
11© 2016 NetCracker Technology Corporation Confidential
PreparedStatement
Connection con = ...;
PreparedStatement ps =
con.prepareStatement("SELECT...");
...
ps.close();
12© 2016 NetCracker Technology Corporation Confidential
Smoker’s approach to PostgreSQL
PARSE S_1 as ...; // con.prepareStmt
BIND/EXEC
DEALLOCATE // ps.close()
PARSE S_2 as ...;
BIND/EXEC
DEALLOCATE // ps.close()
13© 2016 NetCracker Technology Corporation Confidential
Healthy approach to PostgreSQL
PARSE S_1 as ...;
BIND/EXEC
BIND/EXEC
BIND/EXEC
BIND/EXEC
BIND/EXEC
...
DEALLOCATE
14© 2016 NetCracker Technology Corporation Confidential
Healthy approach to PostgreSQL
PARSE S_1 as ...;  1 once in a life
BIND/EXEC  REST call
BIND/EXEC
BIND/EXEC  one more REST call
BIND/EXEC
BIND/EXEC
...
DEALLOCATE  “never” is the best
15© 2016 NetCracker Technology Corporation Confidential
Happiness closes no statements
Conclusion №1: in order to get top performance,
you should not close statements
ps = con.prepareStatement(...)
ps.execueQuery();
ps = con.prepareStatement(...)
ps.execueQuery();
...
16© 2016 NetCracker Technology Corporation Confidential
Happiness closes no statements
Conclusion №1: in order to get top performance,
you should not close statements
ps = con.prepare...
ps.execueQuery();
ps = con.prepare...
ps.execueQuery();
...
17© 2016 NetCracker Technology Corporation Confidential
Unclosed statements in practice
@Benchmark
public Statement leakStatement() {
return con.createStatement();
}
pgjdbc < 9.4.1202, -Xmx128m, OracleJDK 1.8u40
# Warmup Iteration 1: 1147,070 ns/op
# Warmup Iteration 2: 12101,537 ns/op
# Warmup Iteration 3: 90825,971 ns/op
# Warmup Iteration 4: <failure>
java.lang.OutOfMemoryError: GC overhead limit
exceeded
18© 2016 NetCracker Technology Corporation Confidential
Unclosed statements in practice
@Benchmark
public Statement leakStatement() {
return con.createStatement();
}
pgjdbc >= 9.4.1202, -Xmx128m, OracleJDK 1.8u40
# Warmup Iteration 1: 30 ns/op
# Warmup Iteration 2: 27 ns/op
# Warmup Iteration 3: 30 ns/op
...
19© 2016 NetCracker Technology Corporation Confidential
Statements in practice
‱ In practice, application is always closing the
statements
‱ PostgreSQL has no shared query cache
‱ Nobody wants spending excessive time on
planning
20© 2016 NetCracker Technology Corporation Confidential
Server-prepared statements
What can we do about it?
‱ Wrap all the queries in PL/PgSQL
‱ It helps, however we had 100500 SQL of them
‱ Teach JDBC to cache queries
21© 2016 NetCracker Technology Corporation Confidential
Query cache in PgJDBC
‱ Query cache was implemented in 9.4.1202 (2015-
08-27)
see https://github.com/pgjdbc/pgjdbc/pull/319
‱ Is transparent to the application
‱ We did not bother considering PL/PgSQL again
‱ Server-prepare is activated after 5 executions
(prepareThreshold)
22© 2016 NetCracker Technology Corporation Confidential
Where are the numbers?
‱ Of course, planning time depends on the query
complexity
‱ We observed 20ĐŒŃ+ planning time for OLTP
queries: 10KiB query, 170 lines explain
‱ Result is ~0ms
23© 2016 NetCracker Technology Corporation Confidential
Overheads
24© 2016 NetCracker Technology Corporation Confidential
Generated queries are bad
‱ If a query is generated
‱ It results in a brand new java.lang.String object
‱ Thus you have to recompute its hashCode
25© 2016 NetCracker Technology Corporation Confidential
Parameter types
If the type of bind value changes, you have to
recreate server-prepared statement
ps.setInt(1, 42);
...
ps.setNull(1, Types.VARCHAR);
26© 2016 NetCracker Technology Corporation Confidential
Parameter types
If the type of bind value changes, you have to
recreate server-prepared statement
ps.setInt(1, 42);
...
ps.setNull(1, Types.VARCHAR);
It leads to DEALLOCATE  PREPARE
27© 2016 NetCracker Technology Corporation Confidential
Keep data type the same
Conclusion №1
‱ Even NULL values should be properly typed
28© 2016 NetCracker Technology Corporation Confidential
Unexpected degradation
If using prepared statements, the response time
gets 5'000 times slower. How’s that possible?
A. Bug C. Feature
B. Feature D. Bug
29© 2016 NetCracker Technology Corporation Confidential
Unexpected degradation
https://gist.github.com/vlsi -> 01_plan_flipper.sql
select *
from plan_flipper -- <- table
where skewed = 0 -- 1M rows
and non_skewed = 42 -- 20 rows
30© 2016 NetCracker Technology Corporation Confidential
Unexpected degradation
https://gist.github.com/vlsi -> 01_plan_flipper.sql
0.1ms  1st execution
0.05ms  2nd execution
0.05ms  3rd execution
0.05ms  4th execution
0.05ms  5th execution
250 ms  6th execution
31© 2016 NetCracker Technology Corporation Confidential
Unexpected degradation
https://gist.github.com/vlsi -> 01_plan_flipper.sql
0.1ms  1st execution
0.05ms  2nd execution
0.05ms  3rd execution
0.05ms  4th execution
0.05ms  5th execution
250 ms  6th execution
32© 2016 NetCracker Technology Corporation Confidential
Unexpected degradation
‱ Who is to blame?
‱ PostgreSQL switches to generic plan after 5
executions of a server-prepared statement
‱ What can we do about it?
‱ Add +0, OFFSET 0, and so on
‱ Pay attention on plan validation
‱ Discuss the phenomenon pgsql-hackers
33© 2016 NetCracker Technology Corporation Confidential
Unexpected degradation
https://gist.github.com/vlsi -> 01_plan_flipper.sql
We just use +0 to forbid index on a bad column
select *
from plan_flipper
where skewed+0 = 0  ~ /*+no_index*/
and non_skewed = 42
34© 2016 NetCracker Technology Corporation Confidential
Explain explain explain explain
The rule of 6 explains:
prepare x(number) as select ...;
explain analyze execute x(42); -- 1ms
explain analyze execute x(42); -- 1ms
explain analyze execute x(42); -- 1ms
explain analyze execute x(42); -- 1ms
explain analyze execute x(42); -- 1ms
explain analyze execute x(42); -- 10 sec
35© 2016 NetCracker Technology Corporation Confidential
ВДзЎД баг
36© 2016 NetCracker Technology Corporation Confidential
Decision problem
There’s a schema A with table X, and a schema B
with table X. What is the result of select * from
X?
A.X C. Error
B.X D. All of the above
37© 2016 NetCracker Technology Corporation Confidential
Search_path
There’s a schema A with table X, and a schema B
with table X. What is the result of select * from
X?
‱ search_path determines the schema used
‱ server-prepared statements are not prepared for
search_path changes  crazy things might
happen
38© 2016 NetCracker Technology Corporation Confidential
Search_path can go wrong
‱ 9.1 will just use old OIDs and execute the “previous”
query
‱ 9.2-9.5 might fail with "cached plan must not change
result type” error
39© 2016 NetCracker Technology Corporation Confidential
Search_path
What can we do about it?
‱ Keep search_path constant
‱ Discuss it in pgsql-hackers
‱ Set search_path + server-prepared statements =
cached plan must not change result type
‱ PL/pgSQL has exactly the same issue 
40© 2016 NetCracker Technology Corporation Confidential
To fetch or not to fetch
You are to fetch 1M rows 1KiB each, -Xmx128m
while (resultSet.next())
resultSet.getString(1);
A. No problem C. Must use
LIMIT/OFFSET
B. OutOfMemory D. autoCommit(false)
41© 2016 NetCracker Technology Corporation Confidential
To fetch or not to fetch
‱ PgJDBC fetches all rows by default
‱ To fetch in batches, you need
Statement.setFetchSize and
connection.setAutoCommit(false)
‱ Default value is configurable via
defaultRowFetchSize (9.4.1202+)
42© 2016 NetCracker Technology Corporation Confidential
fetchSize vs fetch time
6.48
2.28
1.76
1.04 0.97
0
2
4
6
8
10 50 100 1000 2000
Faster,ms
fetchSize
2000 rows
2000 rows
select int4, int4, int4, int4
43© 2016 NetCracker Technology Corporation Confidential
FetchSize is good for stability
Conclusion №2:
‱ For stability & performance reasons set
defaultRowFetchSize >= 100
44© 2016 NetCracker Technology Corporation Confidential
Data upload
For data uploads, use
‱ INSERT() VALUES()
‱ INSERT() SELECT ?, ?, ?
‱ INSERT() VALUES()  executeBatch
‱ INSERT() VALUES(), (), ()  executeBatch
‱ COPY
45© 2016 NetCracker Technology Corporation Confidential
Healty batch INSERT
PARSE S_1 as ...;
BIND/EXEC
BIND/EXEC
BIND/EXEC
BIND/EXEC
BIND/EXEC
...
DEALLOCATE
46© 2016 NetCracker Technology Corporation Confidential
TCP strikes back
JDBC is busy with sending
queries, thus it has not started
fetching responses yet
DB cannot fetch more queries since it
is busy with sending responses
47© 2016 NetCracker Technology Corporation Confidential
Batch INSERT in real life
PARSE S_1 as ...;
BIND/EXEC
BIND/EXEC
SYNC  flush & wait for the response
BIND/EXEC
BIND/EXEC
SYNC  flush & wait for the response
...
48© 2016 NetCracker Technology Corporation Confidential
TCP deadlock avoidance
‱ PgJDBC adds SYNC to your nice batch operations
‱ The more the SYNCs the slower it performs
49© 2016 NetCracker Technology Corporation Confidential
Horror stories
A single line patch makes insert batch 10 times faster:
https://github.com/pgjdbc/pgjdbc/pull/380
- static int QUERY_FORCE_DESCRIBE_PORTAL = 128;
+ static int QUERY_FORCE_DESCRIBE_PORTAL = 512;
...
// 128 has already been used
static int QUERY_DISALLOW_BATCHING = 128;
50© 2016 NetCracker Technology Corporation Confidential
Trust but always measure
‱ Java 1.8u40+
‱ Core i7 2.6Ghz
‱ Java microbenchmark harness
‱ PostgreSQL 9.5
51© 2016 NetCracker Technology Corporation Confidential
Queries under test: INSERT
pgjdbc/ubenchmark/InsertBatch.java
insert into batch_perf_test(a, b, c)
values(?, ?, ?)
52© 2016 NetCracker Technology Corporation Confidential
Queries under test: INSERT
pgjdbc/ubenchmark/InsertBatch.java
insert into batch_perf_test(a, b, c)
values(?, ?, ?)
53© 2016 NetCracker Technology Corporation Confidential
Queries under test: INSERT
pgjdbc/ubenchmark/InsertBatch.java
insert into batch_perf_test(a, b, c)
values (?, ?, ?), (?, ?, ?), (?, ?,
?), (?, ?, ?), (?, ?, ?), (?, ?, ?),
(?, ?, ?), (?, ?, ?), (?, ?, ?), ...;
54© 2016 NetCracker Technology Corporation Confidential
ĐąĐ”ŃŃ‚ĐžŃ€ŃƒĐ”ĐŒŃ‹Đ” Đ·Đ°ĐżŃ€ĐŸŃŃ‹: COPY
pgjdbc/ubenchmark/InsertBatch.java
COPY batch_perf_test FROM STDIN
1 s1 1
2 s2 2
3 s3 3
...
55© 2016 NetCracker Technology Corporation Confidential
Queries under test: hand-made structs
pgjdbc/ubenchmark/InsertBatch.java
insert into batch_perf_test
select * from
unnest('{"(1,s1,1)","(2,s2,2)",
"(3,s3,3)"}'::batch_perf_test[])
56© 2016 NetCracker Technology Corporation Confidential
You’d better use batch, your C.O.
2
16
128
0
50
100
150
16 128 1024
faster,ms
The number of inserted rows
Insert
Batch
Struct
Copy
int4, varchar, int4
57© 2016 NetCracker Technology Corporation Confidential
COPY is good
0
0.5
1
1.5
2
2.5
16 128 1024
Faster,ms
The number of inserted rows
Batch
Struct
Copy
int4, varchar, int4
58© 2016 NetCracker Technology Corporation Confidential
COPY is bad for small batches
0
5
10
15
20
25
1 4 8 16 128
Faster,ms
Batch size in rows
Batch
Struct
Copy
Insert of 1024 rows
59© 2016 NetCracker Technology Corporation Confidential
Final thoughts
‱ PreparedStatement is our hero
‱ Remember to EXPLAIN ANALYZE at least six
times, a blue moon is a plus
‱ Don’t forget +0 and OFFSET 0
60© 2016 NetCracker Technology Corporation Confidential
About me
‱ Vladimir Sitnikov, @VladimirSitnikv
‱ Performance architect in NetCracker
‱ 10 years of experience with Java/SQL
‱ PgJDBC committer
© 2016 NetCracker Technology Corporation Confidential
Questions?
Vladimir Sitnikov,
PgConf 2016

Mais conteĂșdo relacionado

Mais procurados

Working with JSON Data in PostgreSQL vs. MongoDB
Working with JSON Data in PostgreSQL vs. MongoDBWorking with JSON Data in PostgreSQL vs. MongoDB
Working with JSON Data in PostgreSQL vs. MongoDBScaleGrid.io
 
Why your Spark Job is Failing
Why your Spark Job is FailingWhy your Spark Job is Failing
Why your Spark Job is FailingDataWorks Summit
 
Evening out the uneven: dealing with skew in Flink
Evening out the uneven: dealing with skew in FlinkEvening out the uneven: dealing with skew in Flink
Evening out the uneven: dealing with skew in FlinkFlink Forward
 
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark ApplicationsTop 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark ApplicationsCloudera, Inc.
 
Understanding and Improving Code Generation
Understanding and Improving Code GenerationUnderstanding and Improving Code Generation
Understanding and Improving Code GenerationDatabricks
 
MySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsMySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsOSSCube
 
Introduction to Apache Camel
Introduction to Apache CamelIntroduction to Apache Camel
Introduction to Apache CamelClaus Ibsen
 
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...Altinity Ltd
 
From Zero to Hero with Kafka Connect
From Zero to Hero with Kafka ConnectFrom Zero to Hero with Kafka Connect
From Zero to Hero with Kafka Connectconfluent
 
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the CloudAmazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the CloudNoritaka Sekiyama
 
APACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka StreamsAPACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka StreamsKetan Gote
 
How the Postgres Query Optimizer Works
How the Postgres Query Optimizer WorksHow the Postgres Query Optimizer Works
How the Postgres Query Optimizer WorksEDB
 
Facebook Presto presentation
Facebook Presto presentationFacebook Presto presentation
Facebook Presto presentationCyanny LIANG
 
Building Robust ETL Pipelines with Apache Spark
Building Robust ETL Pipelines with Apache SparkBuilding Robust ETL Pipelines with Apache Spark
Building Robust ETL Pipelines with Apache SparkDatabricks
 
ClickHouse Deep Dive, by Aleksei Milovidov
ClickHouse Deep Dive, by Aleksei MilovidovClickHouse Deep Dive, by Aleksei Milovidov
ClickHouse Deep Dive, by Aleksei MilovidovAltinity Ltd
 
PostgreSQL Performance Tuning
PostgreSQL Performance TuningPostgreSQL Performance Tuning
PostgreSQL Performance Tuningelliando dias
 
Where is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in FlinkWhere is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in FlinkFlink Forward
 

Mais procurados (20)

Working with JSON Data in PostgreSQL vs. MongoDB
Working with JSON Data in PostgreSQL vs. MongoDBWorking with JSON Data in PostgreSQL vs. MongoDB
Working with JSON Data in PostgreSQL vs. MongoDB
 
Why your Spark Job is Failing
Why your Spark Job is FailingWhy your Spark Job is Failing
Why your Spark Job is Failing
 
Evening out the uneven: dealing with skew in Flink
Evening out the uneven: dealing with skew in FlinkEvening out the uneven: dealing with skew in Flink
Evening out the uneven: dealing with skew in Flink
 
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark ApplicationsTop 5 Mistakes to Avoid When Writing Apache Spark Applications
Top 5 Mistakes to Avoid When Writing Apache Spark Applications
 
PostgreSQL
PostgreSQLPostgreSQL
PostgreSQL
 
Advanced Terraform
Advanced TerraformAdvanced Terraform
Advanced Terraform
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
Understanding and Improving Code Generation
Understanding and Improving Code GenerationUnderstanding and Improving Code Generation
Understanding and Improving Code Generation
 
MySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 TipsMySQL Performance Tuning: Top 10 Tips
MySQL Performance Tuning: Top 10 Tips
 
Introduction to Apache Camel
Introduction to Apache CamelIntroduction to Apache Camel
Introduction to Apache Camel
 
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
 
From Zero to Hero with Kafka Connect
From Zero to Hero with Kafka ConnectFrom Zero to Hero with Kafka Connect
From Zero to Hero with Kafka Connect
 
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the CloudAmazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
 
APACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka StreamsAPACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka Streams
 
How the Postgres Query Optimizer Works
How the Postgres Query Optimizer WorksHow the Postgres Query Optimizer Works
How the Postgres Query Optimizer Works
 
Facebook Presto presentation
Facebook Presto presentationFacebook Presto presentation
Facebook Presto presentation
 
Building Robust ETL Pipelines with Apache Spark
Building Robust ETL Pipelines with Apache SparkBuilding Robust ETL Pipelines with Apache Spark
Building Robust ETL Pipelines with Apache Spark
 
ClickHouse Deep Dive, by Aleksei Milovidov
ClickHouse Deep Dive, by Aleksei MilovidovClickHouse Deep Dive, by Aleksei Milovidov
ClickHouse Deep Dive, by Aleksei Milovidov
 
PostgreSQL Performance Tuning
PostgreSQL Performance TuningPostgreSQL Performance Tuning
PostgreSQL Performance Tuning
 
Where is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in FlinkWhere is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in Flink
 

Destaque

Developing PostgreSQL Performance, Simon Riggs
Developing PostgreSQL Performance, Simon RiggsDeveloping PostgreSQL Performance, Simon Riggs
Developing PostgreSQL Performance, Simon RiggsFuenteovejuna
 
High Performance Jdbc
High Performance JdbcHigh Performance Jdbc
High Performance JdbcSam Pattsin
 
A step-by-step approach toward high quality OutOfMemoryError analysis
A step-by-step approach toward high quality OutOfMemoryError analysisA step-by-step approach toward high quality OutOfMemoryError analysis
A step-by-step approach toward high quality OutOfMemoryError analysisVladimir Sitnikov
 
Implement your own profiler with blackjack and fun
Implement your own profiler with blackjack and funImplement your own profiler with blackjack and fun
Implement your own profiler with blackjack and funVladimir Sitnikov
 
ĐŸŃ€ĐŸĐ±Đ»Đ”ĐŒŃ‹ ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚Đž open source Đ±ĐžĐ±Đ»ĐžĐŸŃ‚Đ”Đș
ĐŸŃ€ĐŸĐ±Đ»Đ”ĐŒŃ‹ ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚Đž open source Đ±ĐžĐ±Đ»ĐžĐŸŃ‚Đ”ĐșĐŸŃ€ĐŸĐ±Đ»Đ”ĐŒŃ‹ ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚Đž open source Đ±ĐžĐ±Đ»ĐžĐŸŃ‚Đ”Đș
ĐŸŃ€ĐŸĐ±Đ»Đ”ĐŒŃ‹ ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚Đž open source Đ±ĐžĐ±Đ»ĐžĐŸŃ‚Đ”ĐșVladimir Sitnikov
 
PostgreSQL Đž JDBC: ĐČŃ‹Đ¶ĐžĐŒĐ°Đ”ĐŒ ĐČсД ŃĐŸĐșĐž
PostgreSQL Đž JDBC: ĐČŃ‹Đ¶ĐžĐŒĐ°Đ”ĐŒ ĐČсД ŃĐŸĐșĐžPostgreSQL Đž JDBC: ĐČŃ‹Đ¶ĐžĐŒĐ°Đ”ĐŒ ĐČсД ŃĐŸĐșĐž
PostgreSQL Đž JDBC: ĐČŃ‹Đ¶ĐžĐŒĐ°Đ”ĐŒ ĐČсД ŃĐŸĐșĐžVladimir Sitnikov
 
ĐŸĐŸĐŽĐČĐŸĐŽĐœŃ‹Đ” ĐșĐ°ĐŒĐœĐž ĐČ ĐœĐ°ĐłŃ€ŃƒĐ·ĐŸŃ‡ĐœĐŸĐŒ Ń‚Đ”ŃŃ‚ĐžŃ€ĐŸĐČĐ°ĐœĐžĐž
ĐŸĐŸĐŽĐČĐŸĐŽĐœŃ‹Đ” ĐșĐ°ĐŒĐœĐž ĐČ ĐœĐ°ĐłŃ€ŃƒĐ·ĐŸŃ‡ĐœĐŸĐŒ Ń‚Đ”ŃŃ‚ĐžŃ€ĐŸĐČĐ°ĐœĐžĐžĐŸĐŸĐŽĐČĐŸĐŽĐœŃ‹Đ” ĐșĐ°ĐŒĐœĐž ĐČ ĐœĐ°ĐłŃ€ŃƒĐ·ĐŸŃ‡ĐœĐŸĐŒ Ń‚Đ”ŃŃ‚ĐžŃ€ĐŸĐČĐ°ĐœĐžĐž
ĐŸĐŸĐŽĐČĐŸĐŽĐœŃ‹Đ” ĐșĐ°ĐŒĐœĐž ĐČ ĐœĐ°ĐłŃ€ŃƒĐ·ĐŸŃ‡ĐœĐŸĐŒ Ń‚Đ”ŃŃ‚ĐžŃ€ĐŸĐČĐ°ĐœĐžĐžVladimir Sitnikov
 
ĐĄĐ”ĐŒĐ°ĐœŃ‚ĐžĐșĐ° final ĐżĐŸĐ»Đ”Đč ĐČ java
ĐĄĐ”ĐŒĐ°ĐœŃ‚ĐžĐșĐ° final ĐżĐŸĐ»Đ”Đč ĐČ javaĐĄĐ”ĐŒĐ°ĐœŃ‚ĐžĐșĐ° final ĐżĐŸĐ»Đ”Đč ĐČ java
ĐĄĐ”ĐŒĐ°ĐœŃ‚ĐžĐșĐ° final ĐżĐŸĐ»Đ”Đč ĐČ javaVladimir Sitnikov
 
ĐąŃ€ŃƒĐŽĐŸĐČŃ‹Đ” Đ±ŃƒĐŽĐœĐž ĐžĐœĐ¶Đ”ĐœĐ”Ń€Đ° ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚Đž
ĐąŃ€ŃƒĐŽĐŸĐČŃ‹Đ” Đ±ŃƒĐŽĐœĐž ĐžĐœĐ¶Đ”ĐœĐ”Ń€Đ° ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚ĐžĐąŃ€ŃƒĐŽĐŸĐČŃ‹Đ” Đ±ŃƒĐŽĐœĐž ĐžĐœĐ¶Đ”ĐœĐ”Ń€Đ° ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚Đž
ĐąŃ€ŃƒĐŽĐŸĐČŃ‹Đ” Đ±ŃƒĐŽĐœĐž ĐžĐœĐ¶Đ”ĐœĐ”Ń€Đ° ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚ĐžVladimir Sitnikov
 
Net cracker resource_inventory
Net cracker resource_inventoryNet cracker resource_inventory
Net cracker resource_inventoryPrasant Kella
 
PGDay UK 2016 -- Performace for queries with grouping
PGDay UK 2016 -- Performace for queries with groupingPGDay UK 2016 -- Performace for queries with grouping
PGDay UK 2016 -- Performace for queries with groupingAlexey Bashtanov
 
Logical Replication in PostgreSQL - FLOSSUK 2016
Logical Replication in PostgreSQL - FLOSSUK 2016Logical Replication in PostgreSQL - FLOSSUK 2016
Logical Replication in PostgreSQL - FLOSSUK 2016Petr Jelinek
 
PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6Tomas Vondra
 
Managing replication of PostgreSQL, Simon Riggs
Managing replication of PostgreSQL, Simon RiggsManaging replication of PostgreSQL, Simon Riggs
Managing replication of PostgreSQL, Simon RiggsFuenteovejuna
 
Security Best Practices for your Postgres Deployment
Security Best Practices for your Postgres DeploymentSecurity Best Practices for your Postgres Deployment
Security Best Practices for your Postgres DeploymentPGConf APAC
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performancePostgreSQL-Consulting
 
Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014EDB
 
The hitchhiker's guide to PostgreSQL
The hitchhiker's guide to PostgreSQLThe hitchhiker's guide to PostgreSQL
The hitchhiker's guide to PostgreSQLFederico Campoli
 
5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL PerformanceCommand Prompt., Inc
 

Destaque (20)

Developing PostgreSQL Performance, Simon Riggs
Developing PostgreSQL Performance, Simon RiggsDeveloping PostgreSQL Performance, Simon Riggs
Developing PostgreSQL Performance, Simon Riggs
 
High Performance Jdbc
High Performance JdbcHigh Performance Jdbc
High Performance Jdbc
 
A step-by-step approach toward high quality OutOfMemoryError analysis
A step-by-step approach toward high quality OutOfMemoryError analysisA step-by-step approach toward high quality OutOfMemoryError analysis
A step-by-step approach toward high quality OutOfMemoryError analysis
 
Implement your own profiler with blackjack and fun
Implement your own profiler with blackjack and funImplement your own profiler with blackjack and fun
Implement your own profiler with blackjack and fun
 
ĐŸŃ€ĐŸĐ±Đ»Đ”ĐŒŃ‹ ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚Đž open source Đ±ĐžĐ±Đ»ĐžĐŸŃ‚Đ”Đș
ĐŸŃ€ĐŸĐ±Đ»Đ”ĐŒŃ‹ ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚Đž open source Đ±ĐžĐ±Đ»ĐžĐŸŃ‚Đ”ĐșĐŸŃ€ĐŸĐ±Đ»Đ”ĐŒŃ‹ ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚Đž open source Đ±ĐžĐ±Đ»ĐžĐŸŃ‚Đ”Đș
ĐŸŃ€ĐŸĐ±Đ»Đ”ĐŒŃ‹ ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚Đž open source Đ±ĐžĐ±Đ»ĐžĐŸŃ‚Đ”Đș
 
PostgreSQL Đž JDBC: ĐČŃ‹Đ¶ĐžĐŒĐ°Đ”ĐŒ ĐČсД ŃĐŸĐșĐž
PostgreSQL Đž JDBC: ĐČŃ‹Đ¶ĐžĐŒĐ°Đ”ĐŒ ĐČсД ŃĐŸĐșĐžPostgreSQL Đž JDBC: ĐČŃ‹Đ¶ĐžĐŒĐ°Đ”ĐŒ ĐČсД ŃĐŸĐșĐž
PostgreSQL Đž JDBC: ĐČŃ‹Đ¶ĐžĐŒĐ°Đ”ĐŒ ĐČсД ŃĐŸĐșĐž
 
ĐŸĐŸĐŽĐČĐŸĐŽĐœŃ‹Đ” ĐșĐ°ĐŒĐœĐž ĐČ ĐœĐ°ĐłŃ€ŃƒĐ·ĐŸŃ‡ĐœĐŸĐŒ Ń‚Đ”ŃŃ‚ĐžŃ€ĐŸĐČĐ°ĐœĐžĐž
ĐŸĐŸĐŽĐČĐŸĐŽĐœŃ‹Đ” ĐșĐ°ĐŒĐœĐž ĐČ ĐœĐ°ĐłŃ€ŃƒĐ·ĐŸŃ‡ĐœĐŸĐŒ Ń‚Đ”ŃŃ‚ĐžŃ€ĐŸĐČĐ°ĐœĐžĐžĐŸĐŸĐŽĐČĐŸĐŽĐœŃ‹Đ” ĐșĐ°ĐŒĐœĐž ĐČ ĐœĐ°ĐłŃ€ŃƒĐ·ĐŸŃ‡ĐœĐŸĐŒ Ń‚Đ”ŃŃ‚ĐžŃ€ĐŸĐČĐ°ĐœĐžĐž
ĐŸĐŸĐŽĐČĐŸĐŽĐœŃ‹Đ” ĐșĐ°ĐŒĐœĐž ĐČ ĐœĐ°ĐłŃ€ŃƒĐ·ĐŸŃ‡ĐœĐŸĐŒ Ń‚Đ”ŃŃ‚ĐžŃ€ĐŸĐČĐ°ĐœĐžĐž
 
ĐĄĐ”ĐŒĐ°ĐœŃ‚ĐžĐșĐ° final ĐżĐŸĐ»Đ”Đč ĐČ java
ĐĄĐ”ĐŒĐ°ĐœŃ‚ĐžĐșĐ° final ĐżĐŸĐ»Đ”Đč ĐČ javaĐĄĐ”ĐŒĐ°ĐœŃ‚ĐžĐșĐ° final ĐżĐŸĐ»Đ”Đč ĐČ java
ĐĄĐ”ĐŒĐ°ĐœŃ‚ĐžĐșĐ° final ĐżĐŸĐ»Đ”Đč ĐČ java
 
ĐąŃ€ŃƒĐŽĐŸĐČŃ‹Đ” Đ±ŃƒĐŽĐœĐž ĐžĐœĐ¶Đ”ĐœĐ”Ń€Đ° ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚Đž
ĐąŃ€ŃƒĐŽĐŸĐČŃ‹Đ” Đ±ŃƒĐŽĐœĐž ĐžĐœĐ¶Đ”ĐœĐ”Ń€Đ° ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚ĐžĐąŃ€ŃƒĐŽĐŸĐČŃ‹Đ” Đ±ŃƒĐŽĐœĐž ĐžĐœĐ¶Đ”ĐœĐ”Ń€Đ° ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚Đž
ĐąŃ€ŃƒĐŽĐŸĐČŃ‹Đ” Đ±ŃƒĐŽĐœĐž ĐžĐœĐ¶Đ”ĐœĐ”Ń€Đ° ĐżŃ€ĐŸĐžĐ·ĐČĐŸĐŽĐžŃ‚Đ”Đ»ŃŒĐœĐŸŃŃ‚Đž
 
Net cracker resource_inventory
Net cracker resource_inventoryNet cracker resource_inventory
Net cracker resource_inventory
 
Final field semantics
Final field semanticsFinal field semantics
Final field semantics
 
PGDay UK 2016 -- Performace for queries with grouping
PGDay UK 2016 -- Performace for queries with groupingPGDay UK 2016 -- Performace for queries with grouping
PGDay UK 2016 -- Performace for queries with grouping
 
Logical Replication in PostgreSQL - FLOSSUK 2016
Logical Replication in PostgreSQL - FLOSSUK 2016Logical Replication in PostgreSQL - FLOSSUK 2016
Logical Replication in PostgreSQL - FLOSSUK 2016
 
PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6
 
Managing replication of PostgreSQL, Simon Riggs
Managing replication of PostgreSQL, Simon RiggsManaging replication of PostgreSQL, Simon Riggs
Managing replication of PostgreSQL, Simon Riggs
 
Security Best Practices for your Postgres Deployment
Security Best Practices for your Postgres DeploymentSecurity Best Practices for your Postgres Deployment
Security Best Practices for your Postgres Deployment
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performance
 
Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014Postgres in Production - Best Practices 2014
Postgres in Production - Best Practices 2014
 
The hitchhiker's guide to PostgreSQL
The hitchhiker's guide to PostgreSQLThe hitchhiker's guide to PostgreSQL
The hitchhiker's guide to PostgreSQL
 
5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance
 

Semelhante a PostgreSQL and JDBC: striving for high performance

Linux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance ShowdownLinux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance ShowdownScyllaDB
 
MongoDB World 2019: Why NBCUniversal Migrated to MongoDB Atlas
MongoDB World 2019: Why NBCUniversal Migrated to MongoDB AtlasMongoDB World 2019: Why NBCUniversal Migrated to MongoDB Atlas
MongoDB World 2019: Why NBCUniversal Migrated to MongoDB AtlasMongoDB
 
Slices Of Performance in Java - Oleksandr Bodnar
Slices Of Performance in Java - Oleksandr BodnarSlices Of Performance in Java - Oleksandr Bodnar
Slices Of Performance in Java - Oleksandr BodnarGlobalLogic Ukraine
 
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...HostedbyConfluent
 
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streaming
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to StreamingBravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streaming
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to StreamingYaroslav Tkachenko
 
DataStax Enterprise & Apache Cassandra – Essentials for Financial Services – ...
DataStax Enterprise & Apache Cassandra – Essentials for Financial Services – ...DataStax Enterprise & Apache Cassandra – Essentials for Financial Services – ...
DataStax Enterprise & Apache Cassandra – Essentials for Financial Services – ...Daniel Cohen
 
Kubecon seattle 2018 workshop slides
Kubecon seattle 2018 workshop slidesKubecon seattle 2018 workshop slides
Kubecon seattle 2018 workshop slidesWeaveworks
 
Testing Persistent Storage Performance in Kubernetes with Sherlock
Testing Persistent Storage Performance in Kubernetes with SherlockTesting Persistent Storage Performance in Kubernetes with Sherlock
Testing Persistent Storage Performance in Kubernetes with SherlockScyllaDB
 
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...Databricks
 
Test strategies for data processing pipelines
Test strategies for data processing pipelinesTest strategies for data processing pipelines
Test strategies for data processing pipelinesLars Albertsson
 
High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)Arnaud Bouchez
 
The Performance Engineer's Guide to Java (HotSpot) Virtual Machine
The Performance Engineer's Guide to Java (HotSpot) Virtual MachineThe Performance Engineer's Guide to Java (HotSpot) Virtual Machine
The Performance Engineer's Guide to Java (HotSpot) Virtual MachineMonica Beckwith
 
Time series denver an introduction to prometheus
Time series denver   an introduction to prometheusTime series denver   an introduction to prometheus
Time series denver an introduction to prometheusBob Cotton
 
Getting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafGetting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafMasatoshi Tada
 
Performance is not an Option - gRPC and Cassandra
Performance is not an Option - gRPC and CassandraPerformance is not an Option - gRPC and Cassandra
Performance is not an Option - gRPC and CassandraDave Bechberger
 
Dsdt meetup 2017 11-21
Dsdt meetup 2017 11-21Dsdt meetup 2017 11-21
Dsdt meetup 2017 11-21JDA Labs MTL
 
DSDT Meetup Nov 2017
DSDT Meetup Nov 2017DSDT Meetup Nov 2017
DSDT Meetup Nov 2017DSDT_MTL
 
JFokus Java 9 contended locking performance
JFokus Java 9 contended locking performanceJFokus Java 9 contended locking performance
JFokus Java 9 contended locking performanceMonica Beckwith
 
Perf tuning with-multitenant
Perf tuning with-multitenantPerf tuning with-multitenant
Perf tuning with-multitenantJacques Kostic
 
JavaOne 2016: Code Generation with JavaCompiler for Fun, Speed and Business P...
JavaOne 2016: Code Generation with JavaCompiler for Fun, Speed and Business P...JavaOne 2016: Code Generation with JavaCompiler for Fun, Speed and Business P...
JavaOne 2016: Code Generation with JavaCompiler for Fun, Speed and Business P...Juan Cruz Nores
 

Semelhante a PostgreSQL and JDBC: striving for high performance (20)

Linux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance ShowdownLinux Kernel vs DPDK: HTTP Performance Showdown
Linux Kernel vs DPDK: HTTP Performance Showdown
 
MongoDB World 2019: Why NBCUniversal Migrated to MongoDB Atlas
MongoDB World 2019: Why NBCUniversal Migrated to MongoDB AtlasMongoDB World 2019: Why NBCUniversal Migrated to MongoDB Atlas
MongoDB World 2019: Why NBCUniversal Migrated to MongoDB Atlas
 
Slices Of Performance in Java - Oleksandr Bodnar
Slices Of Performance in Java - Oleksandr BodnarSlices Of Performance in Java - Oleksandr Bodnar
Slices Of Performance in Java - Oleksandr Bodnar
 
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streamin...
 
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streaming
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to StreamingBravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streaming
Bravo Six, Going Realtime. Transitioning Activision Data Pipeline to Streaming
 
DataStax Enterprise & Apache Cassandra – Essentials for Financial Services – ...
DataStax Enterprise & Apache Cassandra – Essentials for Financial Services – ...DataStax Enterprise & Apache Cassandra – Essentials for Financial Services – ...
DataStax Enterprise & Apache Cassandra – Essentials for Financial Services – ...
 
Kubecon seattle 2018 workshop slides
Kubecon seattle 2018 workshop slidesKubecon seattle 2018 workshop slides
Kubecon seattle 2018 workshop slides
 
Testing Persistent Storage Performance in Kubernetes with Sherlock
Testing Persistent Storage Performance in Kubernetes with SherlockTesting Persistent Storage Performance in Kubernetes with Sherlock
Testing Persistent Storage Performance in Kubernetes with Sherlock
 
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
Spark SQL Catalyst Code Optimization using Function Outlining with Kavana Bha...
 
Test strategies for data processing pipelines
Test strategies for data processing pipelinesTest strategies for data processing pipelines
Test strategies for data processing pipelines
 
High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)High Performance Object Pascal Code on Servers (at EKON 22)
High Performance Object Pascal Code on Servers (at EKON 22)
 
The Performance Engineer's Guide to Java (HotSpot) Virtual Machine
The Performance Engineer's Guide to Java (HotSpot) Virtual MachineThe Performance Engineer's Guide to Java (HotSpot) Virtual Machine
The Performance Engineer's Guide to Java (HotSpot) Virtual Machine
 
Time series denver an introduction to prometheus
Time series denver   an introduction to prometheusTime series denver   an introduction to prometheus
Time series denver an introduction to prometheus
 
Getting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafGetting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with Thymeleaf
 
Performance is not an Option - gRPC and Cassandra
Performance is not an Option - gRPC and CassandraPerformance is not an Option - gRPC and Cassandra
Performance is not an Option - gRPC and Cassandra
 
Dsdt meetup 2017 11-21
Dsdt meetup 2017 11-21Dsdt meetup 2017 11-21
Dsdt meetup 2017 11-21
 
DSDT Meetup Nov 2017
DSDT Meetup Nov 2017DSDT Meetup Nov 2017
DSDT Meetup Nov 2017
 
JFokus Java 9 contended locking performance
JFokus Java 9 contended locking performanceJFokus Java 9 contended locking performance
JFokus Java 9 contended locking performance
 
Perf tuning with-multitenant
Perf tuning with-multitenantPerf tuning with-multitenant
Perf tuning with-multitenant
 
JavaOne 2016: Code Generation with JavaCompiler for Fun, Speed and Business P...
JavaOne 2016: Code Generation with JavaCompiler for Fun, Speed and Business P...JavaOne 2016: Code Generation with JavaCompiler for Fun, Speed and Business P...
JavaOne 2016: Code Generation with JavaCompiler for Fun, Speed and Business P...
 

Último

WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 

Último (20)

WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Abortion Pill Prices Tembisa [(+27832195400*)] đŸ„ Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] đŸ„ Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] đŸ„ Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] đŸ„ Women's Abortion Clinic in T...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 

PostgreSQL and JDBC: striving for high performance

  • 1. © 2016 NetCracker Technology Corporation Confidential PostgreSQL and JDBC: striving for top performance Vladimir Sitnikov PgConf 2016
  • 2. 2© 2016 NetCracker Technology Corporation Confidential About me ‱ Vladimir Sitnikov, @VladimirSitnikv ‱ Performance architect at NetCracker ‱ 10 years of experience with Java/SQL ‱ PgJDBC committer
  • 3. 3© 2016 NetCracker Technology Corporation Confidential Explain (analyze, buffers) PostgreSQL and JDBC ‱Data fetch ‱Data upload ‱Performance ‱Pitfalls
  • 4. 4© 2016 NetCracker Technology Corporation Confidential Intro Fetch of a single row via primary key lookup takes 20ms. Localhost. Database is fully cached A. Just fine C. Kidding? Aim is 1ms! B. It should be 1sec D. 100us
  • 5. 5© 2016 NetCracker Technology Corporation Confidential Lots of small queries is a problem Suppose a single query takes 10ms, then 100 of them would take a whole second * * Your Captain
  • 6. 6© 2016 NetCracker Technology Corporation Confidential PostgreSQL frontend-backend protocol ‱Simple query ‱ 'Q' + length + query_text ‱Extended query ‱Parse, Bind, Execute commands
  • 7. 7© 2016 NetCracker Technology Corporation Confidential PostgreSQL frontend-backend protocol Super extended query https://github.com/pgjdbc/pgjdbc/pull/478 backend protocol wanted features
  • 8. 8© 2016 NetCracker Technology Corporation Confidential PostgreSQL frontend-backend protocol Simple query ‱Works well for one-time queries ‱Does not support binary transfer
  • 9. 9© 2016 NetCracker Technology Corporation Confidential PostgreSQL frontend-backend protocol Extended query ‱Eliminates planning time ‱Supports binary transfer
  • 10. 10© 2016 NetCracker Technology Corporation Confidential PreparedStatement Connection con = ...; PreparedStatement ps = con.prepareStatement("SELECT..."); ... ps.close();
  • 11. 11© 2016 NetCracker Technology Corporation Confidential PreparedStatement Connection con = ...; PreparedStatement ps = con.prepareStatement("SELECT..."); ... ps.close();
  • 12. 12© 2016 NetCracker Technology Corporation Confidential Smoker’s approach to PostgreSQL PARSE S_1 as ...; // con.prepareStmt BIND/EXEC DEALLOCATE // ps.close() PARSE S_2 as ...; BIND/EXEC DEALLOCATE // ps.close()
  • 13. 13© 2016 NetCracker Technology Corporation Confidential Healthy approach to PostgreSQL PARSE S_1 as ...; BIND/EXEC BIND/EXEC BIND/EXEC BIND/EXEC BIND/EXEC ... DEALLOCATE
  • 14. 14© 2016 NetCracker Technology Corporation Confidential Healthy approach to PostgreSQL PARSE S_1 as ...;  1 once in a life BIND/EXEC  REST call BIND/EXEC BIND/EXEC  one more REST call BIND/EXEC BIND/EXEC ... DEALLOCATE  “never” is the best
  • 15. 15© 2016 NetCracker Technology Corporation Confidential Happiness closes no statements Conclusion №1: in order to get top performance, you should not close statements ps = con.prepareStatement(...) ps.execueQuery(); ps = con.prepareStatement(...) ps.execueQuery(); ...
  • 16. 16© 2016 NetCracker Technology Corporation Confidential Happiness closes no statements Conclusion №1: in order to get top performance, you should not close statements ps = con.prepare... ps.execueQuery(); ps = con.prepare... ps.execueQuery(); ...
  • 17. 17© 2016 NetCracker Technology Corporation Confidential Unclosed statements in practice @Benchmark public Statement leakStatement() { return con.createStatement(); } pgjdbc < 9.4.1202, -Xmx128m, OracleJDK 1.8u40 # Warmup Iteration 1: 1147,070 ns/op # Warmup Iteration 2: 12101,537 ns/op # Warmup Iteration 3: 90825,971 ns/op # Warmup Iteration 4: <failure> java.lang.OutOfMemoryError: GC overhead limit exceeded
  • 18. 18© 2016 NetCracker Technology Corporation Confidential Unclosed statements in practice @Benchmark public Statement leakStatement() { return con.createStatement(); } pgjdbc >= 9.4.1202, -Xmx128m, OracleJDK 1.8u40 # Warmup Iteration 1: 30 ns/op # Warmup Iteration 2: 27 ns/op # Warmup Iteration 3: 30 ns/op ...
  • 19. 19© 2016 NetCracker Technology Corporation Confidential Statements in practice ‱ In practice, application is always closing the statements ‱ PostgreSQL has no shared query cache ‱ Nobody wants spending excessive time on planning
  • 20. 20© 2016 NetCracker Technology Corporation Confidential Server-prepared statements What can we do about it? ‱ Wrap all the queries in PL/PgSQL ‱ It helps, however we had 100500 SQL of them ‱ Teach JDBC to cache queries
  • 21. 21© 2016 NetCracker Technology Corporation Confidential Query cache in PgJDBC ‱ Query cache was implemented in 9.4.1202 (2015- 08-27) see https://github.com/pgjdbc/pgjdbc/pull/319 ‱ Is transparent to the application ‱ We did not bother considering PL/PgSQL again ‱ Server-prepare is activated after 5 executions (prepareThreshold)
  • 22. 22© 2016 NetCracker Technology Corporation Confidential Where are the numbers? ‱ Of course, planning time depends on the query complexity ‱ We observed 20ĐŒŃ+ planning time for OLTP queries: 10KiB query, 170 lines explain ‱ Result is ~0ms
  • 23. 23© 2016 NetCracker Technology Corporation Confidential Overheads
  • 24. 24© 2016 NetCracker Technology Corporation Confidential Generated queries are bad ‱ If a query is generated ‱ It results in a brand new java.lang.String object ‱ Thus you have to recompute its hashCode
  • 25. 25© 2016 NetCracker Technology Corporation Confidential Parameter types If the type of bind value changes, you have to recreate server-prepared statement ps.setInt(1, 42); ... ps.setNull(1, Types.VARCHAR);
  • 26. 26© 2016 NetCracker Technology Corporation Confidential Parameter types If the type of bind value changes, you have to recreate server-prepared statement ps.setInt(1, 42); ... ps.setNull(1, Types.VARCHAR); It leads to DEALLOCATE  PREPARE
  • 27. 27© 2016 NetCracker Technology Corporation Confidential Keep data type the same Conclusion №1 ‱ Even NULL values should be properly typed
  • 28. 28© 2016 NetCracker Technology Corporation Confidential Unexpected degradation If using prepared statements, the response time gets 5'000 times slower. How’s that possible? A. Bug C. Feature B. Feature D. Bug
  • 29. 29© 2016 NetCracker Technology Corporation Confidential Unexpected degradation https://gist.github.com/vlsi -> 01_plan_flipper.sql select * from plan_flipper -- <- table where skewed = 0 -- 1M rows and non_skewed = 42 -- 20 rows
  • 30. 30© 2016 NetCracker Technology Corporation Confidential Unexpected degradation https://gist.github.com/vlsi -> 01_plan_flipper.sql 0.1ms  1st execution 0.05ms  2nd execution 0.05ms  3rd execution 0.05ms  4th execution 0.05ms  5th execution 250 ms  6th execution
  • 31. 31© 2016 NetCracker Technology Corporation Confidential Unexpected degradation https://gist.github.com/vlsi -> 01_plan_flipper.sql 0.1ms  1st execution 0.05ms  2nd execution 0.05ms  3rd execution 0.05ms  4th execution 0.05ms  5th execution 250 ms  6th execution
  • 32. 32© 2016 NetCracker Technology Corporation Confidential Unexpected degradation ‱ Who is to blame? ‱ PostgreSQL switches to generic plan after 5 executions of a server-prepared statement ‱ What can we do about it? ‱ Add +0, OFFSET 0, and so on ‱ Pay attention on plan validation ‱ Discuss the phenomenon pgsql-hackers
  • 33. 33© 2016 NetCracker Technology Corporation Confidential Unexpected degradation https://gist.github.com/vlsi -> 01_plan_flipper.sql We just use +0 to forbid index on a bad column select * from plan_flipper where skewed+0 = 0  ~ /*+no_index*/ and non_skewed = 42
  • 34. 34© 2016 NetCracker Technology Corporation Confidential Explain explain explain explain The rule of 6 explains: prepare x(number) as select ...; explain analyze execute x(42); -- 1ms explain analyze execute x(42); -- 1ms explain analyze execute x(42); -- 1ms explain analyze execute x(42); -- 1ms explain analyze execute x(42); -- 1ms explain analyze execute x(42); -- 10 sec
  • 35. 35© 2016 NetCracker Technology Corporation Confidential ВДзЎД баг
  • 36. 36© 2016 NetCracker Technology Corporation Confidential Decision problem There’s a schema A with table X, and a schema B with table X. What is the result of select * from X? A.X C. Error B.X D. All of the above
  • 37. 37© 2016 NetCracker Technology Corporation Confidential Search_path There’s a schema A with table X, and a schema B with table X. What is the result of select * from X? ‱ search_path determines the schema used ‱ server-prepared statements are not prepared for search_path changes  crazy things might happen
  • 38. 38© 2016 NetCracker Technology Corporation Confidential Search_path can go wrong ‱ 9.1 will just use old OIDs and execute the “previous” query ‱ 9.2-9.5 might fail with "cached plan must not change result type” error
  • 39. 39© 2016 NetCracker Technology Corporation Confidential Search_path What can we do about it? ‱ Keep search_path constant ‱ Discuss it in pgsql-hackers ‱ Set search_path + server-prepared statements = cached plan must not change result type ‱ PL/pgSQL has exactly the same issue 
  • 40. 40© 2016 NetCracker Technology Corporation Confidential To fetch or not to fetch You are to fetch 1M rows 1KiB each, -Xmx128m while (resultSet.next()) resultSet.getString(1); A. No problem C. Must use LIMIT/OFFSET B. OutOfMemory D. autoCommit(false)
  • 41. 41© 2016 NetCracker Technology Corporation Confidential To fetch or not to fetch ‱ PgJDBC fetches all rows by default ‱ To fetch in batches, you need Statement.setFetchSize and connection.setAutoCommit(false) ‱ Default value is configurable via defaultRowFetchSize (9.4.1202+)
  • 42. 42© 2016 NetCracker Technology Corporation Confidential fetchSize vs fetch time 6.48 2.28 1.76 1.04 0.97 0 2 4 6 8 10 50 100 1000 2000 Faster,ms fetchSize 2000 rows 2000 rows select int4, int4, int4, int4
  • 43. 43© 2016 NetCracker Technology Corporation Confidential FetchSize is good for stability Conclusion №2: ‱ For stability & performance reasons set defaultRowFetchSize >= 100
  • 44. 44© 2016 NetCracker Technology Corporation Confidential Data upload For data uploads, use ‱ INSERT() VALUES() ‱ INSERT() SELECT ?, ?, ? ‱ INSERT() VALUES()  executeBatch ‱ INSERT() VALUES(), (), ()  executeBatch ‱ COPY
  • 45. 45© 2016 NetCracker Technology Corporation Confidential Healty batch INSERT PARSE S_1 as ...; BIND/EXEC BIND/EXEC BIND/EXEC BIND/EXEC BIND/EXEC ... DEALLOCATE
  • 46. 46© 2016 NetCracker Technology Corporation Confidential TCP strikes back JDBC is busy with sending queries, thus it has not started fetching responses yet DB cannot fetch more queries since it is busy with sending responses
  • 47. 47© 2016 NetCracker Technology Corporation Confidential Batch INSERT in real life PARSE S_1 as ...; BIND/EXEC BIND/EXEC SYNC  flush & wait for the response BIND/EXEC BIND/EXEC SYNC  flush & wait for the response ...
  • 48. 48© 2016 NetCracker Technology Corporation Confidential TCP deadlock avoidance ‱ PgJDBC adds SYNC to your nice batch operations ‱ The more the SYNCs the slower it performs
  • 49. 49© 2016 NetCracker Technology Corporation Confidential Horror stories A single line patch makes insert batch 10 times faster: https://github.com/pgjdbc/pgjdbc/pull/380 - static int QUERY_FORCE_DESCRIBE_PORTAL = 128; + static int QUERY_FORCE_DESCRIBE_PORTAL = 512; ... // 128 has already been used static int QUERY_DISALLOW_BATCHING = 128;
  • 50. 50© 2016 NetCracker Technology Corporation Confidential Trust but always measure ‱ Java 1.8u40+ ‱ Core i7 2.6Ghz ‱ Java microbenchmark harness ‱ PostgreSQL 9.5
  • 51. 51© 2016 NetCracker Technology Corporation Confidential Queries under test: INSERT pgjdbc/ubenchmark/InsertBatch.java insert into batch_perf_test(a, b, c) values(?, ?, ?)
  • 52. 52© 2016 NetCracker Technology Corporation Confidential Queries under test: INSERT pgjdbc/ubenchmark/InsertBatch.java insert into batch_perf_test(a, b, c) values(?, ?, ?)
  • 53. 53© 2016 NetCracker Technology Corporation Confidential Queries under test: INSERT pgjdbc/ubenchmark/InsertBatch.java insert into batch_perf_test(a, b, c) values (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), (?, ?, ?), ...;
  • 54. 54© 2016 NetCracker Technology Corporation Confidential ĐąĐ”ŃŃ‚ĐžŃ€ŃƒĐ”ĐŒŃ‹Đ” Đ·Đ°ĐżŃ€ĐŸŃŃ‹: COPY pgjdbc/ubenchmark/InsertBatch.java COPY batch_perf_test FROM STDIN 1 s1 1 2 s2 2 3 s3 3 ...
  • 55. 55© 2016 NetCracker Technology Corporation Confidential Queries under test: hand-made structs pgjdbc/ubenchmark/InsertBatch.java insert into batch_perf_test select * from unnest('{"(1,s1,1)","(2,s2,2)", "(3,s3,3)"}'::batch_perf_test[])
  • 56. 56© 2016 NetCracker Technology Corporation Confidential You’d better use batch, your C.O. 2 16 128 0 50 100 150 16 128 1024 faster,ms The number of inserted rows Insert Batch Struct Copy int4, varchar, int4
  • 57. 57© 2016 NetCracker Technology Corporation Confidential COPY is good 0 0.5 1 1.5 2 2.5 16 128 1024 Faster,ms The number of inserted rows Batch Struct Copy int4, varchar, int4
  • 58. 58© 2016 NetCracker Technology Corporation Confidential COPY is bad for small batches 0 5 10 15 20 25 1 4 8 16 128 Faster,ms Batch size in rows Batch Struct Copy Insert of 1024 rows
  • 59. 59© 2016 NetCracker Technology Corporation Confidential Final thoughts ‱ PreparedStatement is our hero ‱ Remember to EXPLAIN ANALYZE at least six times, a blue moon is a plus ‱ Don’t forget +0 and OFFSET 0
  • 60. 60© 2016 NetCracker Technology Corporation Confidential About me ‱ Vladimir Sitnikov, @VladimirSitnikv ‱ Performance architect in NetCracker ‱ 10 years of experience with Java/SQL ‱ PgJDBC committer
  • 61. © 2016 NetCracker Technology Corporation Confidential Questions? Vladimir Sitnikov, PgConf 2016