tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Anderson <>
Subject [PATCH] JDBCStore.keys() doesn't scale well
Date Tue, 04 Feb 2003 21:39:35 GMT
As currently written, JDBCStore pulls session IDs from the database 
using a query of the form:
	SELECT COUNT(, FROM tomcat_sessions s, tomcat_sessions c 

While this query is a clever way to get the count back as part of the 
query, it does not scale well to larger numbers of sessions.   I had 
about 5000 sessions in a moderately loaded system with a MySQL database 
and this query would take about 80 seconds to run by hand because of 
the N-squared nature of joining the table with itself.

This much simpler query is not as clever but gets the job done much 
more efficiently (it only takes 0.00 seconds according to mysql):
	SELECT id FROM tomcat_sessions;

It means a little more work determining the number of IDs after the 
query runs but it's more than worth it.

Attached is the patch file.


View raw message