Skip to content

Commit 461c1f4

Browse files
author
Dmitry Mishin
committed
DB optimizations: added key, added connection auto check in pool
!!! nodes table: add (path, container_id) key - speed up 10X
1 parent 18eed92 commit 461c1f4

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

sql/vospace.sql

+31-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# http://code.google.com/p/sequel-pro/
77
#
88
# Host: swiftnode01 (MySQL 5.6.12-log)
9-
# Database: scidrive
10-
# Generation Time: 2013-09-06 20:22:39 +0000
9+
# Database: vobox
10+
# Generation Time: 2014-02-25 01:16:37 +0000
1111
# ************************************************************
1212

1313

@@ -139,6 +139,7 @@ CREATE TABLE `nodes` (
139139
PRIMARY KEY (`node_id`),
140140
KEY `container_id` (`container_id`),
141141
KEY `parent_node_id` (`parent_node_id`),
142+
KEY `path` (`path`,`container_id`),
142143
CONSTRAINT `container_id` FOREIGN KEY (`container_id`) REFERENCES `containers` (`container_id`) ON DELETE CASCADE ON UPDATE CASCADE,
143144
CONSTRAINT `nodes_ibfk_1` FOREIGN KEY (`parent_node_id`) REFERENCES `nodes` (`node_id`) ON DELETE CASCADE ON UPDATE CASCADE
144145
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -162,6 +163,8 @@ CREATE TABLE `oauth_accessors` (
162163
UNIQUE KEY `access_token` (`access_token`),
163164
KEY `container_id` (`container_id`),
164165
KEY `share_key` (`share_key`),
166+
KEY `consumer_id` (`consumer_id`),
167+
CONSTRAINT `oauth_accessors_ibfk_3` FOREIGN KEY (`consumer_id`) REFERENCES `oauth_consumers` (`consumer_id`) ON DELETE CASCADE ON UPDATE CASCADE,
165168
CONSTRAINT `oauth_accessors_ibfk_1` FOREIGN KEY (`container_id`) REFERENCES `containers` (`container_id`) ON DELETE CASCADE ON UPDATE CASCADE,
166169
CONSTRAINT `oauth_accessors_ibfk_2` FOREIGN KEY (`share_key`) REFERENCES `container_shares` (`share_key`) ON DELETE CASCADE ON UPDATE CASCADE
167170
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@@ -206,6 +209,32 @@ CREATE TABLE `oauth_nonces` (
206209

207210

208211

212+
# Dump of table openid_associations
213+
# ------------------------------------------------------------
214+
215+
CREATE TABLE `openid_associations` (
216+
`opurl` varchar(255) NOT NULL DEFAULT '',
217+
`handle` varchar(255) NOT NULL DEFAULT '',
218+
`type` varchar(255) NOT NULL DEFAULT '',
219+
`mackey` varchar(255) NOT NULL DEFAULT '',
220+
`expdate` datetime NOT NULL,
221+
PRIMARY KEY (`handle`)
222+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
223+
224+
225+
226+
# Dump of table openid_nonces
227+
# ------------------------------------------------------------
228+
229+
CREATE TABLE `openid_nonces` (
230+
`opurl` varchar(255) NOT NULL DEFAULT '',
231+
`nonce` varchar(255) NOT NULL DEFAULT '',
232+
`date` datetime NOT NULL,
233+
PRIMARY KEY (`opurl`,`nonce`)
234+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
235+
236+
237+
209238
# Dump of table properties
210239
# ------------------------------------------------------------
211240

src/edu/jhu/pha/vospace/DbPoolServlet.java

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public void init() throws ServletException {
5757
pool.setMinEvictableIdleTimeMillis(6*60*60*1000);
5858
pool.setTimeBetweenEvictionRunsMillis(30*60*1000);
5959
pool.setNumTestsPerEvictionRun(-1);
60+
pool.setTestOnBorrow(true); // !!!!!!!!!! test connection before giving it
6061

6162
DriverManagerConnectionFactory cf = new DriverManagerConnectionFactory(conf.getString("db.url"), conf.getString("db.login"), conf.getString("db.password"));
6263

0 commit comments

Comments
 (0)