Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add index to log table #1330

Merged
merged 3 commits into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions configuration/etl/etl.d/xdmod-migration-8_5_1-9_0_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@
}
}
},
{
"name": "update-mod_logger-log_table-table",
"description": "Update mod_logger.log_table table",
"namespace": "ETL\\Maintenance",
"class": "ExecuteSql",
"options_class": "MaintenanceOptions",
"sql_file_list": [
"migrations/8.5.1-9.0.0/logger/alter-log-table.sql"
],
"endpoints": {
"destination": {
"type": "mysql",
"name": "Logger Database",
"config": "logger",
"schema": "mod_logger"
}
}
},
{
"name": "OpenStackDomainToSubmissionVenueMappingStagingIngestor",
"description": "Load schema version history",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- Add index to the `log_table` table. This table is not managed by an ETL
-- definition.

-- Wrap the ALTER TABLE statement in a prepared statement that conditionally
-- add the column so that this file can be executed multiple times without
-- causing errors.
SET @statement = (
SELECT IF(
(
SELECT COUNT(*) FROM information_schema.statistics
WHERE table_schema = '${DESTINATION_SCHEMA}'
AND table_name = 'log_table'
AND index_name = 'get_messages_idx'
) > 0,
'SELECT 1',
CONCAT(
'ALTER TABLE `${DESTINATION_SCHEMA}`.`log_table` ',
'ADD INDEX `get_messages_idx` (`ident`,`logtime`,`priority`)'
)
)
)//
PREPARE addIndexIfNotExists FROM @statement//
EXECUTE addIndexIfNotExists//
DEALLOCATE PREPARE addIndexIfNotExists//
3 changes: 2 additions & 1 deletion db/schema/mod_logger.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ CREATE TABLE `log_table` (
KEY `unique_id_idx` (`id`),
KEY `ident_idx` (`ident`),
KEY `priority_idx` (`priority`),
KEY `logscan` (`ident`,`priority`,`id`)
KEY `logscan` (`ident`,`priority`,`id`),
KEY `get_messages_idx` (`ident`,`logtime`,`priority`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `schema_version_history`;
Expand Down