ChrisW
ChrisW

Reputation: 372

Can I delete records from event_store_events table?

I am using RailsEventStore with a Mysql DB and am concerned about how big the tables are getting in the DB.

The event_store_events table is now approximately 460GB and the event_store_events_in_streams is approximately 15GB.

Is there anything that could prevent me from deleting them?

I understand that deleting records will break the chain of events and prevent me from replaying them, but for my use case I don't think that is an issue.

Specifically I am using RailsEventStore version 2.3.0

The tables themselves are the standard ones created by RailsEventStore:

mysql> SHOW CREATE TABLE event_store_events\G
*************************** 1. row ***************************
       Table: event_store_events
Create Table: CREATE TABLE `event_store_events` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `event_id` varchar(36) NOT NULL,
  `event_type` varchar(255) NOT NULL,
  `metadata` blob,
  `data` blob NOT NULL,
  `created_at` datetime(6) NOT NULL,
  `valid_at` datetime(6) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `index_event_store_events_on_event_id` (`event_id`),
  KEY `index_event_store_events_on_created_at` (`created_at`),
  KEY `index_event_store_events_on_valid_at` (`valid_at`),
  KEY `index_event_store_events_on_event_type` (`event_type`)
) ENGINE=InnoDB AUTO_INCREMENT=60555061 DEFAULT CHARSET=latin1
1 row in set (0.01 sec)

mysql> _
mysql> SHOW CREATE TABLE event_store_events_in_streams\G
*************************** 1. row ***************************
       Table: event_store_events_in_streams
Create Table: CREATE TABLE `event_store_events_in_streams` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `stream` varchar(255) NOT NULL,
  `position` int(11) DEFAULT NULL,
  `event_id` varchar(36) NOT NULL,
  `created_at` datetime(6) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `index_event_store_events_in_streams_on_stream_and_event_id` (`stream`,`event_id`),
  UNIQUE KEY `index_event_store_events_in_streams_on_stream_and_position` (`stream`,`position`),
  KEY `index_event_store_events_in_streams_on_created_at` (`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=60555061 DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

mysql> _

Upvotes: 0

Views: 62

Answers (0)

Related Questions