You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Craig George (JIRA)" <ji...@apache.org> on 2012/11/21 03:50:57 UTC

[jira] [Updated] (MAILBOX-186) Missing indices on JPA mailstore database results in poor mailbox listing as the number of messages grows

     [ https://issues.apache.org/jira/browse/MAILBOX-186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Craig George updated MAILBOX-186:
---------------------------------

    Description: 
We have an application which queries the IMAP store of Apache James 3 in the following manner:

final Message[] messages = this.folder.getMessages();
final FetchProfile fetchProfile = new FetchProfile();
fetchProfile.add(Item.ENVELOPE);
fetchProfile.add(Item.FLAGS);
fetchProfile.add(Item.CONTENT_INFO);
fetchProfile.add(IMAPFolder.FetchProfileItem.HEADERS);
fetchProfile.add(IMAPFolder.FetchProfileItem.SIZE);
fetchProfile.add(UIDFolder.FetchProfileItem.UID);
this.folder.fetch(messages, fetchProfile);

When this query is performed on a folder with a large number of messages the response times degrade very quickly. This is due to the following query being run *for each* message:

SELECT t0.PROPERTY_ID,
    t0.PROPERTY_LINE_NUMBER,
    t0.PROPERTY_LOCAL_NAME,
    t0.PROPERTY_NAME_SPACE,
    t0.PROPERTY_VALUE
FROM MA_DIRECT_APACHE_JAMES.JAMES_MAIL_PROPERTY t0
WHERE t0.MAILBOX_ID = :1
AND t0.MAIL_UID = :2
ORDER BY t0.PROPERTY_LINE_NUMBER ASC

The problem is that in the {{JAMES_MAIL_PROPERTY}} table only the {{PROPERTY_LINE_ID}} column is indexed, implicity by virtue of the fact that it is the primary key. The workaround is to add the following indexes on the table:

CREATE INDEX I_JMS_MIL_PROPERTY_MSG_ID ON JAMES_MAIL_PROPERTY (MAILBOX_ID, MAIL_UID);
CREATE INDEX I_JMS_MIL_PROPERTY_LINE_NUMBER ON JAMES_MAIL_PROPERTY (PROPERTY_LINE_NUMBER);


  was:
We have an application which queries the IMAP store of Apache James 3 in the following manner:
{code}
final Message[] messages = this.folder.getMessages();
final FetchProfile fetchProfile = new FetchProfile();
fetchProfile.add(Item.ENVELOPE);
fetchProfile.add(Item.FLAGS);
fetchProfile.add(Item.CONTENT_INFO);
fetchProfile.add(IMAPFolder.FetchProfileItem.HEADERS);
fetchProfile.add(IMAPFolder.FetchProfileItem.SIZE);
fetchProfile.add(UIDFolder.FetchProfileItem.UID);
this.folder.fetch(messages, fetchProfile);
{code}
When this query is performed on a folder with a large number of messages the response times degrade very quickly. This is due to the following query being run *for each* message:
{code:sql}
SELECT t0.PROPERTY_ID,
    t0.PROPERTY_LINE_NUMBER,
    t0.PROPERTY_LOCAL_NAME,
    t0.PROPERTY_NAME_SPACE,
    t0.PROPERTY_VALUE
FROM MA_DIRECT_APACHE_JAMES.JAMES_MAIL_PROPERTY t0
WHERE t0.MAILBOX_ID = :1
AND t0.MAIL_UID = :2
ORDER BY t0.PROPERTY_LINE_NUMBER ASC
{code}
The problem is that in the {{JAMES_MAIL_PROPERTY}} table only the {{PROPERTY_LINE_ID}} column is indexed, implicity by virtue of the fact that it is the primary key. The workaround is to add the following indexes on the table:
{code:sql}
CREATE INDEX I_JMS_MIL_PROPERTY_MSG_ID ON JAMES_MAIL_PROPERTY (MAILBOX_ID, MAIL_UID);
CREATE INDEX I_JMS_MIL_PROPERTY_LINE_NUMBER ON JAMES_MAIL_PROPERTY (PROPERTY_LINE_NUMBER);
{code}

    
> Missing indices on JPA mailstore database results in poor mailbox listing as the number of messages grows
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: MAILBOX-186
>                 URL: https://issues.apache.org/jira/browse/MAILBOX-186
>             Project: James Mailbox
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 0.4
>            Reporter: Craig George
>
> We have an application which queries the IMAP store of Apache James 3 in the following manner:
> final Message[] messages = this.folder.getMessages();
> final FetchProfile fetchProfile = new FetchProfile();
> fetchProfile.add(Item.ENVELOPE);
> fetchProfile.add(Item.FLAGS);
> fetchProfile.add(Item.CONTENT_INFO);
> fetchProfile.add(IMAPFolder.FetchProfileItem.HEADERS);
> fetchProfile.add(IMAPFolder.FetchProfileItem.SIZE);
> fetchProfile.add(UIDFolder.FetchProfileItem.UID);
> this.folder.fetch(messages, fetchProfile);
> When this query is performed on a folder with a large number of messages the response times degrade very quickly. This is due to the following query being run *for each* message:
> SELECT t0.PROPERTY_ID,
>     t0.PROPERTY_LINE_NUMBER,
>     t0.PROPERTY_LOCAL_NAME,
>     t0.PROPERTY_NAME_SPACE,
>     t0.PROPERTY_VALUE
> FROM MA_DIRECT_APACHE_JAMES.JAMES_MAIL_PROPERTY t0
> WHERE t0.MAILBOX_ID = :1
> AND t0.MAIL_UID = :2
> ORDER BY t0.PROPERTY_LINE_NUMBER ASC
> The problem is that in the {{JAMES_MAIL_PROPERTY}} table only the {{PROPERTY_LINE_ID}} column is indexed, implicity by virtue of the fact that it is the primary key. The workaround is to add the following indexes on the table:
> CREATE INDEX I_JMS_MIL_PROPERTY_MSG_ID ON JAMES_MAIL_PROPERTY (MAILBOX_ID, MAIL_UID);
> CREATE INDEX I_JMS_MIL_PROPERTY_LINE_NUMBER ON JAMES_MAIL_PROPERTY (PROPERTY_LINE_NUMBER);

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org