forked from linagora/james-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JAMES-2586 ADR for Posgres mailbox tables structure (linagora#1857)
- Loading branch information
1 parent
609d9a5
commit 2c23b76
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# 68. Native PostgreSQL adoption | ||
# 70. Native PostgreSQL adoption | ||
|
||
Date: 2023-10-31 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# 71. Postgresql Mailbox tables structure | ||
|
||
Date: 2023-12-14 | ||
|
||
## Status | ||
|
||
Implemented | ||
|
||
## Context | ||
|
||
As described in [ADR-70](link), we are willing to provide a Postgres implementation for Apache James. | ||
The current document is willing to detail the inner working of the mailbox of the target implementation. | ||
|
||
## Decision | ||
|
||
![diagram for mailbox tables](img/adr-71-mailbox-tables-diagram.png) | ||
|
||
Table list: | ||
- mailbox | ||
- mailbox_annotations | ||
- message | ||
- message_mailbox | ||
- subscription | ||
|
||
Indexes in table message_mailbox: | ||
- message_mailbox_message_id_index (message_id) | ||
- mailbox_id_mail_uid_index (mailbox_id, message_uid) | ||
- mailbox_id_is_seen_mail_uid_index (mailbox_id, is_seen, message_uid) | ||
- mailbox_id_is_recent_mail_uid_index (mailbox_id, is_recent, message_uid) | ||
- mailbox_id_is_delete_mail_uid_index (mailbox_id, is_deleted, message_uid) | ||
|
||
Indexes are used to find records faster. | ||
|
||
The table structure is mostly normalized which mitigates storage costs and achieves consistency easily. | ||
|
||
Foreign key constraints (mailbox_id in mailbox_annotations, message_id in message_mailbox) help to ensure data consistency. For example, message_id 1 in table message_mailbox could not exist if message_id 1 in table message does not exist | ||
|
||
For some fields, hstore data type are used. Hstore is key-value hashmap data structure. Hstore allows us to model complex data types without the need for complex joins. | ||
|
||
Special postgres clauses such as RETURNING, ON CONFLICT are used to ensure consistency without the need of combining multiple queries in a single transaction. | ||
|
||
## Consequences | ||
|
||
Pros: | ||
- Indexes could increase query performance significantly | ||
|
||
Cons: | ||
- Too many indexes in a table could reduce the performance of updating data in the table | ||
|
||
## Alternatives | ||
|
||
## References | ||
|
||
- [JIRA](https://issues.apache.org/jira/browse/JAMES-2586) | ||
- [PostgreSQL](https://www.postgresql.org/) | ||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.