Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Changed

- The `events` table `type` modified to include both `id` and `type` ([#69]).
- This change should not affect existing applications. However, it is **recommended** to apply similar changes to the `events` table by adding a new index.
- To create a new index, the following SQL could be executed manually on event store database:
```sql
CREATE INDEX events_id_type_index ON events ("id", "type");
```
Keep in mind that creating a new index will lock the table. To prevent that, you can use the following SQL:
```sql
CREATE INDEX CONCURRENTLY events_id_type_index ON events ("id", "type");
```
Read more about creating index on [PostgreSQL documentation](https://www.postgresql.org/docs/current/sql-createindex.html).
- (optional) To drop the existing `type` index, the following SQL could be executed manually on event store database:
```sql
DROP INDEX events_type_index;
```
Note that you might need to keep this index if you have a custom script that uses the index.
- _The above queries are suggestion so feel free to modify existing indexes as you wish._

## [0.9.0] - 2021-11-18

### Added
Expand Down
2 changes: 1 addition & 1 deletion lib/event_sourcery/postgres/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def create_events(db: EventSourcery::Postgres.config.event_store_database,
column :created_at, :'timestamp without time zone', null: false, default: Sequel.lit("(now() at time zone 'utc')")
index [:aggregate_id, :version], unique: true
index :uuid, unique: true
index :type
index [:id, :type]
Copy link

@Domon Domon Oct 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will be affected by this change?

I did a quick search of the create_events and create_event_store methods in this repo but I only found their usage in the benchmarking scripts and test setup. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the above index will have impact on EventSourcery::Postgres::EventStore#get_next_from method performance.

Copy link

@Domon Domon Nov 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that adding the index to each application's events table will improve the performance of the get_next_from method.

My questions is more about what is depending on this schema file and what will be benefited from this change.

In the changelog, it is mentioned that this change doesn't affect existing projects. That made me wonder what is the outcome of this change.

If someone creates a new Event Sourcery project, will the latest schema from this file be used somehow?

index :correlation_id
index :causation_id
index :created_at
Expand Down