spring-projects / spring-projects/spring-session
Optimize JDBC update and retrieval logic
Nobody has claimed this yet.
- 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
commitcalls. - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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