Skip to content

Commit 77609d6

Browse files
author
William Durkin
committed
fix #63 - adding defaults to the collection_metadata table
1 parent ed5c3db commit 77609d6

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

setup/install_open_query_store_base.sql

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,32 @@ IF NOT EXISTS ( SELECT * FROM [sys].[schemas] AS [S] WHERE [S].[name] = 'oqs' )
4141
EXEC ( 'CREATE SCHEMA oqs' );
4242
END;
4343
GO
44-
45-
-- Metadata to control OQS
4644
CREATE TABLE [oqs].[collection_metadata]
4745
(
4846
[command] nvarchar (2000) NOT NULL, -- The command that should be executed by Service Broker
4947
[collection_interval] bigint NOT NULL, -- The interval for looped processing (in seconds)
50-
[oqs_mode] varchar (11) NOT NULL, -- The mode that OQS should run in. May only be "classic" or "centralized"
48+
[oqs_mode] varchar (11) NOT NULL, -- The mode that OQS should run in. May only be "classic" or "centralized"
5149
[oqs_classic_db] nvarchar (128) NOT NULL, -- The database where OQS resides in classic mode (must be filled when classic mode is chosen, ignored by centralized mode)
5250
[collection_active] bit NOT NULL, -- Should OQS be collecting data or not
5351
[execution_threshold] tinyint NOT NULL, -- The minimum executions of a query plan before we consider it for capture in OQS
5452
[data_cleanup_active] bit NOT NULL, -- Should OQS automatically clean up old data
5553
[data_cleanup_threshold] tinyint NOT NULL, -- How many days should OQS keep data for (automated cleanup removes data older than this)
5654
[data_cleanup_throttle] smallint NOT NULL, -- How many rows can be deleted in one pass. This avoids large deletions from trashing the transaction log and blocking OQS tables.
57-
CONSTRAINT [chk_oqs_mode] CHECK ( [oqs_mode] IN ( N'classic', N'centralized' ))
55+
5856
);
5957
GO
6058

59+
-- We want to have defaults and checks for certain settings
60+
ALTER TABLE [oqs].[collection_metadata]
61+
ADD CONSTRAINT [chk_oqs_mode] CHECK ( [oqs_mode] IN ( N'classic', N'centralized' )),
62+
CONSTRAINT [df_collection_interval] DEFAULT ( 60 ) FOR [collection_interval],
63+
CONSTRAINT [df_collection_active] DEFAULT ( 0 ) FOR [collection_active],
64+
CONSTRAINT [df_execution_threshold] DEFAULT ( 2 ) FOR [execution_threshold],
65+
CONSTRAINT [df_cleanup_active] DEFAULT ( 0 ) FOR [data_cleanup_active],
66+
CONSTRAINT [df_cleanup_threshold] DEFAULT ( 2 ) FOR [data_cleanup_threshold],
67+
CONSTRAINT [df_cleanup_throttle] DEFAULT ( 5000 ) FOR [data_cleanup_throttle];
68+
69+
6170
-- Semi-hidden way of documenting the version of OQS that is installed. The value will be automatically bumped upon a new version build/release
6271
EXEC sys.sp_addextendedproperty @name=N'oqs_version', @value=N'2.1.0' , @level0type=N'SCHEMA',@level0name=N'oqs', @level1type=N'TABLE',@level1name=N'collection_metadata'
6372
GO
@@ -73,7 +82,7 @@ INSERT INTO [oqs].[collection_metadata] ( [command],
7382
[data_cleanup_threshold],
7483
[data_cleanup_throttle]
7584
)
76-
VALUES ( N'EXEC [oqs].[gather_statistics] @logmode=1', 60 , '{OQSMode}','{DatabaseWhereOQSIsRunning}',0,2,1,30,5000);
85+
VALUES ( N'EXEC [oqs].[gather_statistics] @logmode=1', DEFAULT , '{OQSMode}','{DatabaseWhereOQSIsRunning}',DEFAULT,DEFAULT,DEFAULT,DEFAULT,DEFAULT);
7786
GO
7887

7988
CREATE TABLE [oqs].[activity_log]

0 commit comments

Comments
 (0)