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
EVENT_PUBLICATION insert fails due to big SERIALIZED_EVENT #519
Comments
If you want to use bigger event payloads, you need to adapt the schema definitions declared here to scale up the size of the serialized event column. |
Yes, I use default JDBC PostgreSQL schema CREATE TABLE IF NOT EXISTS event_publication
(
id UUID NOT NULL,
listener_id TEXT NOT NULL,
event_type TEXT NOT NULL,
serialized_event TEXT NOT NULL,
publication_date TIMESTAMP WITH TIME ZONE NOT NULL,
completion_date TIMESTAMP WITH TIME ZONE,
PRIMARY KEY (id)
);
CREATE INDEX IF NOT EXISTS event_publication_by_listener_id_and_serialized_event_idx ON event_publication (listener_id, serialized_event);
CREATE INDEX IF NOT EXISTS event_publication_by_completion_date_idx ON event_publication (completion_date); The index UPDATE EVENT_PUBLICATION
SET COMPLETION_DATE = ?
WHERE
LISTENER_ID = ?
AND SERIALIZED_EVENT = ? This make me think I should care |
I am not a Postgres expert, but it looks like we might need to optimize our index declaration. Would you mind adding |
GIN, GIST index types are dedicated for column types like |
Also running into this issue, in my case I can make events smaller but not sure how long this trick will suffice. |
@odrotbohm what if one introduces another field, a hash of serialised_event and then put index on it? |
Here is my solution, I had to split index into 2:
Unfortunately I could not use JSONB as it is recommended because this is a serialized_event is a TEXT field on JPA in Modulith. |
I'm not sure about other databases, but for PostgreSQL we found that the hash index works well given that Modulith is doing a full equality comparison on the serialized event instead of searching for a substring. And it's not restricted by the size limit that the b-tree index has. We saw a significant performance improvement in the setting of the completion timestamp after adding this index. CREATE INDEX IF NOT EXISTS event_publication_serialized_event_hash_idx ON event_publication USING hash(serialized_event); |
Hi @odrotbohm , in case you missed the post from @JakeTiritilli about the hash index for PostgreSQL, I wanted to bring it to your attention because it dramatically reduced the load on PostgreSQL when the event_publication table had a large volume of records (1+ million in our case during performance testing) for SELECT and UPDATE. The SQL commands are now doing an "Index Scan using event_publication_serialized_event_hash_idx on event_publication" with O(1) ! |
I'll make sure the optimization gets applied in the 1.2 GA release in two weeks and the corresponding service releases for 1.0.x and 1.1.x. |
Spring Modulith: 1.2.0-M2
After introducing indexes on ENVENT_PUBLICATION table (#403) events with bigger payload are not working due to index size limit.
raises error
The text was updated successfully, but these errors were encountered: