chibenwa commented on code in PR #1857:
URL: https://github.com/apache/james-project/pull/1857#discussion_r1427635982


##########
src/adr/0071-postgresql-mailbox-tables-structure.md:
##########
@@ -0,0 +1,44 @@
+# 71.  Postgresql Mailbox tables structure
+
+Date: 2023-12-14
+
+## Status
+
+Implemented
+
+## Context
+
+Apache James was integrated with Postgresql database. The table structure for 
mailbox was created to store mailbox data in Postgresql database.
+
+## Decision
+
+![diagram for mailbox tables](img/adr-71-mailbox-table-diagram.png)
+
+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
+
+For some fields, hstore data type are used. Hstore is key-value hashmap data 
structure. It is useful in some cases. For example, the database needs to store 
a list of usernames and corresponding rights for a mailbox. By applying hstore, 
acl that belongs to a specific mailbox and username could be retrieved quickly.

Review Comment:
   Why do we use hstore?
   
   A: this postgres specific datatypes allows us to model complex data types 
without the need for complex joins.



##########
src/adr/0071-postgresql-mailbox-tables-structure.md:
##########
@@ -0,0 +1,44 @@
+# 71.  Postgresql Mailbox tables structure
+
+Date: 2023-12-14
+
+## Status
+
+Implemented
+
+## Context
+
+Apache James was integrated with Postgresql database. The table structure for 
mailbox was created to store mailbox data in Postgresql database.
+
+## Decision
+
+![diagram for mailbox tables](img/adr-71-mailbox-table-diagram.png)

Review Comment:
   The diagram is nice but it do not replace plain english with a table list.
   
   We are missing annotations on it, annotations is part of the mailbox.
   
   I would also like to have the word **normalized** explicitly mentionned: our 
table structure is mostly normalized which mitigates storage costs and ease 
achiving consistency. Indexes are used for key query in order to improve 
performance.
   
   Also have a word about constraintd



##########
src/adr/0071-postgresql-mailbox-tables-structure.md:
##########
@@ -0,0 +1,44 @@
+# 71.  Postgresql Mailbox tables structure
+
+Date: 2023-12-14
+
+## Status
+
+Implemented
+
+## Context
+
+Apache James was integrated with Postgresql database. The table structure for 
mailbox was created to store mailbox data in Postgresql database.

Review Comment:
   Why Past tense?
   
   I propose: 
   
   ```
   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.
   ```



##########
src/adr/0071-postgresql-mailbox-tables-structure.md:
##########
@@ -0,0 +1,44 @@
+# 71.  Postgresql Mailbox tables structure
+
+Date: 2023-12-14
+
+## Status
+
+Implemented
+
+## Context
+
+Apache James was integrated with Postgresql database. The table structure for 
mailbox was created to store mailbox data in Postgresql database.
+
+## Decision
+
+![diagram for mailbox tables](img/adr-71-mailbox-table-diagram.png)
+
+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
+
+For some fields, hstore data type are used. Hstore is key-value hashmap data 
structure. It is useful in some cases. For example, the database needs to store 
a list of usernames and corresponding rights for a mailbox. By applying hstore, 
acl that belongs to a specific mailbox and username could be retrieved quickly.
+

Review Comment:
   I would like a word on consistency: Using specific postgres construct like 
returning or conflict management we are providing a consistent mailbox 
implementation without the need to rely on transaction thus with limited need 
to trade performance for consistency.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to