Arsnael commented on PR #2792:
URL: https://github.com/apache/james-project/pull/2792#issuecomment-3584128133

   > I wonder if, for the Postgres implementation, we could add an index on the 
needed column(s) and do 1 query to Postgres to get exactly what we need.
   
   Already have indexes...
   
   In `PostgresEmailQueryViewDataDefinition`
   
   ```
           PostgresIndex MAILBOX_ID_INDEX = 
PostgresIndex.name("email_query_view_mailbox_id_index")
               .createIndexStep((dslContext, indexName) -> 
dslContext.createIndexIfNotExists(indexName)
                   .on(TABLE_NAME, MAILBOX_ID));
   
           PostgresIndex MAILBOX_ID_RECEIVED_AT_INDEX = 
PostgresIndex.name("email_query_view_mailbox_id__received_at_index")
               .createIndexStep((dslContext, indexName) -> 
dslContext.createIndexIfNotExists(indexName)
                   .on(TABLE_NAME, MAILBOX_ID, RECEIVED_AT));
   
           PostgresIndex MAILBOX_ID_SENT_AT_INDEX = 
PostgresIndex.name("email_query_view_mailbox_id_sent_at_index")
               .createIndexStep((dslContext, indexName) -> 
dslContext.createIndexIfNotExists(indexName)
                   .on(TABLE_NAME, MAILBOX_ID, SENT_AT));
   ```
   
   Analyzing query running against email_query_view for list by sent at:
   
   <img width="1096" height="855" alt="pg-index-qeury-view" 
src="https://github.com/user-attachments/assets/fa6801d5-dee7-442b-ba88-79fbb7d6d20c";
 />
   
   I dont think we need other indexes?


-- 
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