Changeset 12857 for branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts
- Timestamp:
- 08/13/15 14:51:54 (9 years ago)
- Location:
- branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Initialize Hive Database.sql
r12768 r12857 1 USE [HeuristicLab.Hive-3.3] 2 /* create and initialize hive database tables */ 1 /* HeuristicLab 2 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 3 * 4 * This file is part of HeuristicLab. 5 * 6 * HeuristicLab is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * HeuristicLab is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 USE [HeuristicLab.Hive-3.3] 3 20 4 21 EXEC sp_configure filestream_access_level, 2 -
branches/HiveStatistics/sources/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Prepare Hive Database.sql
r12768 r12857 1 /* HeuristicLab 2 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 3 * 4 * This file is part of HeuristicLab. 5 * 6 * HeuristicLab is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * HeuristicLab is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 /* this script is supposed to be executed after the plain DB is generated by the linq-to-sql schema */ 1 21 USE [HeuristicLab.Hive-3.3] 2 /* this script is supposed to be executed after the plain DB is generated by the linq-to-sql schema */3 /* adds default values */4 /* creates delete and update cascades */5 /* creates indices */6 /* creates views */7 /* creates triggers */8 9 22 10 23 ALTER TABLE [dbo].[AssignedResources] DROP CONSTRAINT [Task_AssignedResource] … … 97 110 GO 98 111 99 /* views */ 100 -- ============================================= 101 -- Author: cneumuel 102 -- Description: Returns the first StateLog entry for each job 103 -- ============================================= 104 CREATE VIEW [dbo].[view_FirstState] 105 AS 106 SELECT sl.TaskId, sl.DateTime, sl.State 107 FROM dbo.StateLog AS sl INNER JOIN 108 (SELECT TaskId, MIN(DateTime) AS DateTime 109 FROM dbo.StateLog 110 GROUP BY TaskId) AS minDate ON sl.DateTime = minDate.DateTime AND sl.TaskId = minDate.TaskId 111 112 -- speed up joins between Job and Task 113 CREATE NONCLUSTERED INDEX [TaskJobIdIndex] 114 ON [dbo].[Task] ([JobId]) 115 INCLUDE ([TaskId],[TaskState],[ExecutionTimeMs],[LastHeartbeat],[ParentTaskId],[Priority],[CoresNeeded],[MemoryNeeded],[IsParentTask],[FinishWhenChildJobsFinished],[Command],[IsPrivileged]) 112 116 GO 113 117 114 -- ============================================= 115 -- Author: cneumuel 116 -- Description: Returns the last StateLog entry for each job 117 -- ============================================= 118 CREATE VIEW [dbo].[view_LastState] 119 AS 120 SELECT sl.TaskId, sl.DateTime, sl.State 121 FROM dbo.StateLog AS sl INNER JOIN 122 (SELECT TaskId, MAX(DateTime) AS DateTime 123 FROM dbo.StateLog 124 GROUP BY TaskId) AS minDate ON sl.DateTime = minDate.DateTime AND sl.TaskId = minDate.TaskId 118 -- this is an index to speed up the GetWaitingTasks() method 119 CREATE NONCLUSTERED INDEX [TaskGetWaitingTasksIndex] 120 ON [dbo].[Task] ([TaskState],[IsParentTask],[FinishWhenChildJobsFinished],[CoresNeeded],[MemoryNeeded]) 121 INCLUDE ([TaskId],[ExecutionTimeMs],[LastHeartbeat],[ParentTaskId],[Priority],[Command],[JobId],[IsPrivileged]) 125 122 GO 123 126 124 127 125 /****** Object: Trigger [dbo].[tr_JobDeleteCascade] Script Date: 04/19/2011 16:31:53 ******/ … … 152 150 CREATE TRIGGER [dbo].[tr_TaskDeleteCascade] ON [dbo].[Task] INSTEAD OF DELETE AS 153 151 BEGIN 154 SELECT155 he.OwnerUserId AS UserId,156 ROUND(SUM(j.ExecutionTimeMs) / 1000, 0) AS ExecutionTimeS,157 ROUND(ISNULL(SUM(CASE ls.State WHEN 'Finished' THEN j.ExecutionTimeMs END), 0) / 1000, 0) AS ExecutionTimeSFinishedJobs,158 ISNULL(SUM(CASE ls.State WHEN 'Finished' THEN DATEDIFF(s, fs.DateTime, ls.DateTime) ELSE 0 END), 0) AS StartToEndTimeS159 FROM160 deleted j,161 Job he,162 view_FirstState fs,163 view_LastState ls164 WHERE165 he.JobId = j.JobId AND166 fs.TaskId = j.TaskId AND167 ls.TaskId = j.TaskId168 GROUP BY he.OwnerUserId169 170 152 -- recursively delete jobs 171 153 CREATE TABLE #Table( … … 194 176 GO 195 177 196 -- ============================================================197 -- Description: Create indices to speed up execution of queries198 -- ============================================================199 178 200 -- speed up joins between Job and Task201 CREATE NONCLUSTERED INDEX [TaskJobIdIndex]202 ON [dbo].[Task] ([JobId])203 INCLUDE ([TaskId],[TaskState],[ExecutionTimeMs],[LastHeartbeat],[ParentTaskId],[Priority],[CoresNeeded],[MemoryNeeded],[IsParentTask],[FinishWhenChildJobsFinished],[Command],[IsPrivileged])204 GO205 206 -- this is an index to speed up the GetWaitingTasks() method207 CREATE NONCLUSTERED INDEX [TaskGetWaitingTasksIndex]208 ON [dbo].[Task] ([TaskState],[IsParentTask],[FinishWhenChildJobsFinished],[CoresNeeded],[MemoryNeeded])209 INCLUDE ([TaskId],[ExecutionTimeMs],[LastHeartbeat],[ParentTaskId],[Priority],[Command],[JobId],[IsPrivileged])210 GO
Note: See TracChangeset
for help on using the changeset viewer.