spring-projects / spring-projects/spring-session

Optimize JDBC update and retrieval logic

Open
#1,073 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
1.9k
Forks
1.2k
Avg merge
4h 27m
Merged PRs (30d)
55

Description

Current optimizations on JDBC Session is good but still have large rooms for optimizations. Each commit of session is resetting state of session and after that each update there is another get call for session as this by getRequestedSessionId:

 else { 
 	S session = wrappedSession.getSession(); 
 	saveSession(session); 
 	String sessionId = session.getId(); 
 	if (!isRequestedSessionIdValid() 
 			|| !sessionId.equals(getRequestedSessionId())) { 
 		SessionRepositoryFilter.this.httpSessionIdResolver.setSessionId(this, 
 				this.response, sessionId); 
 	} 
 } 
  • For a simple request to server there is two commit calls.
  • One of them are calling UPDATE session.
  • Each commit is followed by SELECT.
  • 3 SELECT, 2 UPDATE calls are triggered by each request. These are transactional and thus it around 20 SQL statements are executed per call.

I can understand that session must be committed as early as possible since client issues can happen, but following an UPDATE with a SELECT is not ideal.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the JDBC Session commit path around SessionRepositoryFilter and getRequestedSessionId, focusing on the two commit calls described in the issue. Compare the UPDATE and subsequent SELECT operations for a simple request. Done means reducing redundant database statements without changing session ID handling or commit behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, sql
Domain
backend, databases, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.