db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <Richard.Hille...@Sun.COM>
Subject Re: SELECT query takes 5 secs, what can I do?
Date Tue, 15 Sep 2009 12:32:29 GMT
Hi Andrew,

You might try adding more columns to your index so that it covers the 
whole WHERE clause:

CREATE INDEX IDX_Message_MessageId ON ExchangeSync.Message (messageId, 
archived, id)

Hope this helps,
-Rick



Andrew Bruno wrote:
> Hello,
>
> I have a query that used to take 10secs to run, i.e.
>
> select * from Message m where
> m.messageId='<7997716ED1AF3D47A35D74FA2CB610920255303F@somedomain.com>'
> and m.id != 933927 and m.archived=1
>
> The Message table has around one million rows.
>
> I added the following index
>
> CREATE INDEX IDX_Message_MessageId ON ExchangeSync.Message (messageId)
>
> and now it takes 5secs.
>
> Is there anything else I can do?
>
> Should I add an index on the boolean "archived" column too?
>
> Any performance hints appreciated.
>
> Thanks
> Andrew
>   


Mime
View raw message