Skip to content
Permalink
Browse files

fix: index added to improve performance in #0008640: Huge SQL express…

…ion used to filter test cases without keywords
  • Loading branch information...
fmancardi committed Apr 25, 2019
1 parent dc9586b commit f3532b36f275633e5bfd11a156a405e281baab9f
@@ -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
@@ -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
@@ -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,
@@ -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,
@@ -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;


@@ -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 (
@@ -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");

--
--
@@ -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");


--

0 comments on commit f3532b3

Please sign in to comment.
You can’t perform that action at this time.