Skip to content

Commit

Permalink
fix: index added to improve performance in #0008640: Huge SQL express…
Browse files Browse the repository at this point in the history
…ion used to filter test cases without keywords
  • Loading branch information
fmancardi committed Apr 25, 2019
1 parent dc9586b commit f3532b3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
Expand Up @@ -18,4 +18,7 @@ CREATE OR REPLACE VIEW /*prefix*/latest_exec_by_context
AS SELECT tcversion_id, testplan_id,build_id,platform_id,max(id) AS id
FROM /*prefix*/executions
GROUP BY tcversion_id,testplan_id,build_id,platform_id;



# END
Expand Up @@ -20,4 +20,10 @@ CREATE OR REPLACE VIEW /*prefix*/latest_exec_by_context AS
FROM /*prefix*/executions
GROUP BY tcversion_id,testplan_id,build_id,platform_id
);


CREATE INDEX /*prefix*/nodes_hierarchy_node_type_id ON /*prefix*/nodes_hierarchy ("node_type_id");
CREATE INDEX /*prefix*/idx02_testcase_keywords ON /*prefix*/testcase_keywords ("tcversion_id");


-- END
20 changes: 18 additions & 2 deletions install/sql/mssql/testlink_create_tables.sql
Expand Up @@ -454,6 +454,12 @@ CREATE NONCLUSTERED INDEX /*prefix*/IX_pid_m_nodeorder ON /*prefix*/nodes_hiera
node_order ASC
) ON [PRIMARY];

CREATE NONCLUSTERED INDEX /*prefix*/IX_node_type_id ON /*prefix*/nodes_hierarchy
(
node_type_id ASC
) ON [PRIMARY];


CREATE TABLE /*prefix*/req_coverage (
req_id int NOT NULL,
testcase_id int NOT NULL,
Expand Down Expand Up @@ -569,20 +575,30 @@ CREATE TABLE /*prefix*/role_rights (
) ON [PRIMARY];

CREATE TABLE /*prefix*/testcase_keywords (
id int NOT NULL,
testcase_id int NOT NULL CONSTRAINT /*prefix*/DF_testcase_keywords_testcase_id DEFAULT ((0)),
tcversion_id int NOT NULL CONSTRAINT /*prefix*/DF_testcase_keywords_tcversion_id DEFAULT ((0)),
keyword_id int NOT NULL CONSTRAINT /*prefix*/DF_testcase_keywords_keyword_id DEFAULT ((0)),
CONSTRAINT /*prefix*/PK_testcase_keywords PRIMARY KEY CLUSTERED
CONSTRAINT /*prefix*/PK_testcase_keywords PRIMARY KEY CLUSTERED
(
id
) ON [PRIMARY],
CONSTRAINT /*prefix*/UIX_testcase_keywords UNIQUE NONCLUSTERED
(
testcase_id ASC,
tcversion_id ASC
keyword_id ASC
) ON [PRIMARY]

) ON [PRIMARY];

CREATE NONCLUSTERED INDEX /*prefix*/IX_testcase_keywords ON /*prefix*/testcase_keywords
(
testcase_id ASC
tcversion_id ASC
) ON [PRIMARY];



CREATE TABLE /*prefix*/tcversions (
id int NOT NULL,
tc_external_id int NULL,
Expand Down
6 changes: 4 additions & 2 deletions install/sql/mysql/testlink_create_tables.sql
Expand Up @@ -317,7 +317,8 @@ CREATE TABLE /*prefix*/nodes_hierarchy (
`node_type_id` int(10) unsigned NOT NULL default '1',
`node_order` int(10) unsigned default NULL,
PRIMARY KEY (`id`),
KEY /*prefix*/pid_m_nodeorder (`parent_id`,`node_order`)
KEY /*prefix*/pid_m_nodeorder (`parent_id`,`node_order`),
KEY /*prefix*/nodes_hierarchy_node_type_id (`node_type_id`)
) DEFAULT CHARSET=utf8;


Expand Down Expand Up @@ -435,7 +436,8 @@ CREATE TABLE /*prefix*/testcase_keywords (
`tcversion_id` int(10) unsigned NOT NULL default '0',
`keyword_id` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY /*prefix*/idx01_testcase_keywords (`testcase_id`,`tcversion_id`,`keyword_id`)
UNIQUE KEY /*prefix*/idx01_testcase_keywords (`testcase_id`,`tcversion_id`,`keyword_id`),
KEY /*prefix*/idx02_testcase_keywords (`tcversion_id`)
) DEFAULT CHARSET=utf8;

CREATE TABLE /*prefix*/tcversions (
Expand Down
2 changes: 2 additions & 0 deletions install/sql/postgres/testlink_create_tables.sql
Expand Up @@ -44,6 +44,7 @@ CREATE TABLE /*prefix*/nodes_hierarchy(
PRIMARY KEY ("id")
);
CREATE INDEX /*prefix*/nodes_hierarchy_pid_m_nodeorder ON /*prefix*/nodes_hierarchy ("parent_id","node_order");
CREATE INDEX /*prefix*/nodes_hierarchy_node_type_id ON /*prefix*/nodes_hierarchy ("node_type_id");

--
--
Expand Down Expand Up @@ -604,6 +605,7 @@ CREATE TABLE /*prefix*/testcase_keywords(
PRIMARY KEY ("id")
);
CREATE UNIQUE INDEX /*prefix*/idx01_testcase_keywords ON /*prefix*/testcase_keywords ("testcase_id","tcversion_id","keyword_id");
CREATE INDEX /*prefix*/idx02_testcase_keywords ON /*prefix*/testcase_keywords ("tcversion_id");


--
Expand Down

0 comments on commit f3532b3

Please sign in to comment.