Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0b034a6

Browse filesBrowse files
authored
Add TCP_NODELAY option to improve performance for large response queries (#749)
This commit adds the TCP_NODELAY option to the socket configuration in `configure_socket` function. Without this option, we observed significant performance issues when executing SELECT queries with large responses. Before the fix: postgres=> SELECT repeat('a', 1); SELECT repeat('a', 8153); Time: 1.368 ms Time: 41.364 ms After the fix: postgres=> SELECT repeat('a', 1); SELECT repeat('a', 8153); Time: 1.332 ms Time: 1.528 ms By setting TCP_NODELAY, we eliminate the Nagle's algorithm delay, which results in a substantial improvement in response times for large queries. This problem was discussed in #616.
1 parent 966b8e0 commit 0b034a6
Copy full SHA for 0b034a6

File tree

Expand file treeCollapse file tree

1 file changed

+4
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-0
lines changed

‎src/messages.rs

Copy file name to clipboardExpand all lines: src/messages.rs
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,10 @@ pub fn configure_socket(stream: &TcpStream) {
733733
}
734734
Err(err) => error!("Could not configure socket: {}", err),
735735
}
736+
match sock_ref.set_nodelay(true) {
737+
Ok(_) => (),
738+
Err(err) => error!("Could not configure TCP_NODELAY for socket: {}", err),
739+
}
736740
}
737741

738742
pub trait BytesMutReader {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.