Skip to content
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

POC performance gain with a Email/list method #1496

Open
chibenwa opened this issue Jan 30, 2025 · 2 comments
Open

POC performance gain with a Email/list method #1496

chibenwa opened this issue Jan 30, 2025 · 2 comments
Labels

Comments

@chibenwa
Copy link
Member

chibenwa commented Jan 30, 2025

The idea: combines Email/query and Email/get in one go.

Why? Because it would do a single DB query do load all mails, instead of N.

I am mostly curious to know the possible performance gains with this approach.

I know we would remain 1 read per message for the preview and one other read per message for the headers... But theoretically this could be a 33% perf benefit for INBOX listing, which is quite common so worth a try...

Also it might allow reducing the JSON chatter a bit.

Spec

[ "Email/list", {
  "accountId": "rehielrbnev",
  "mailboxId": "ebverlner",
  "limit": 20,
  "offset": 0,
  "properties": [...]
}, "C0" ]

Definition of done

  • Implement a minimalist version of Email/list
  • Perf test it before / after, adapting gatling scripts as needed
@chibenwa chibenwa added the perf label Jan 30, 2025
@hungphan227 hungphan227 self-assigned this Feb 6, 2025
@hungphan227
Copy link
Contributor

My solution is adding extra columns to CassandraEmailQueryViewTable.

Currenlty, the table looks like:

CassandraModule MODULE = CassandraModule.
        .table(TABLE_NAME_RECEIVED_AT)
        .comment("Storing the JMAP projections for list of emails within a mailbox to not rely on OpenSearch for basic Email/query (sorts and filter on receivedAt).")
        .options(options -> options
            .withClusteringOrder(RECEIVED_AT, DESC)
            .withCaching(true, rows(DEFAULT_CACHED_ROW_PER_PARTITION)))
        .statement(statement -> types -> statement
            .withPartitionKey(MAILBOX_ID, DataTypes.UUID)
            .withClusteringColumn(RECEIVED_AT, DataTypes.TIMESTAMP)
            .withClusteringColumn(MESSAGE_ID, DataTypes.UUID)
            .withColumn(SENT_AT, DataTypes.TIMESTAMP))

I would add some extra fields so that there is no need to query from message table:

CassandraModule MODULE = CassandraModule.
        .table(TABLE_NAME_RECEIVED_AT)
        .comment("Storing the JMAP projections for list of emails within a mailbox to not rely on OpenSearch for basic Email/query (sorts and filter on receivedAt).")
        .options(options -> options
            .withClusteringOrder(RECEIVED_AT, DESC)
            .withCaching(true, rows(DEFAULT_CACHED_ROW_PER_PARTITION)))
        .statement(statement -> types -> statement
            .withPartitionKey(MAILBOX_ID, DataTypes.UUID)
            .withClusteringColumn(RECEIVED_AT, DataTypes.TIMESTAMP)
            .withClusteringColumn(MESSAGE_ID, DataTypes.UUID)
            .withColumn(SENT_AT, DataTypes.TIMESTAMP)
            .withColumn(PREVIEW, DataTypes.TEXT)
            .withColumn(HAS_ATTACHMENT, DataTypes.BOOLEAN)
            .withColumn(Flag.ANSWERED, BOOLEAN)
            .withColumn(Flag.DELETED, BOOLEAN)
            .withColumn(Flag.DRAFT, BOOLEAN)
            .withColumn(Flag.FLAGGED, BOOLEAN)
            .withColumn(Flag.RECENT, BOOLEAN)
            .withColumn(Flag.SEEN, BOOLEAN)
            .withColumn(Flag.USER, BOOLEAN)
            .withColumn(Flag.USER_FLAGS, setOf(TEXT))
            .withColumn(CassandraMessageV3Table.HEADER_CONTENT, TEXT))

@chibenwa
Copy link
Member Author

@hungphan227 please do not take this task.

Pick another development task

My solution is adding extra columns to CassandraEmailQueryViewTable.

Pffff its obvious one should base this on messageidtable

@hungphan227 hungphan227 removed their assignment Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants