Subject | RE: [firebird-support] MAX vs. FIRST 1 |
---|---|
Author | Rick Debay |
Post date | 2007-07-31T20:28:40Z |
There is a bug report in the tracker stating that MAX or MIN takes three
index reads instead of one. FIRST takes only one index read.
-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of PenWin
Sent: Tuesday, July 31, 2007 5:47 AM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] MAX vs. FIRST 1
because I would have expected the database to simply consult the index
and come out with the largest value, as opposed to first selecting all
matching rows, then sorting them and finally returning the first one.
(Assuming I have an applicable index, obviously)
Pepak
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visit http://www.firebirdsql.org and click the Resources item on the
main (top) menu. Try Knowledgebase and FAQ links !
Also search the knowledgebases at http://www.ibphoenix.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo! Groups Links
Disclaimer: This message (including attachments) is confidential and may be privileged. If you have received it by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. RxStrategies, Inc. shall not be liable for the improper or incomplete transmission of the information contained in this communication or for any delay in its receipt or damage to your system. RxStrategies, Inc. does not guarantee that the integrity of this communication has been maintained nor that this communication is free from viruses, interceptions or interference.
index reads instead of one. FIRST takes only one index read.
-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of PenWin
Sent: Tuesday, July 31, 2007 5:47 AM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] MAX vs. FIRST 1
> which of the following two statements would be better or is there someInteresting replies to your question. I always thought MAX is faster
> other statement that I should rather use? There will be in excess of
> 500,000 records per store. It seems to me that the "FIRST 1" would be
> the better one to execute but is it really going to make that much
> difference? I have seen the "SELECT MAX" statement take as long as 16
> minutes when the server is under load, I think that this is due to
> garbage collection. So could I avoid garbage collection by using the
> "FIRST 1"?
because I would have expected the database to simply consult the index
and come out with the largest value, as opposed to first selecting all
matching rows, then sorting them and finally returning the first one.
(Assuming I have an applicable index, obviously)
Pepak
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visit http://www.firebirdsql.org and click the Resources item on the
main (top) menu. Try Knowledgebase and FAQ links !
Also search the knowledgebases at http://www.ibphoenix.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo! Groups Links
Disclaimer: This message (including attachments) is confidential and may be privileged. If you have received it by mistake please notify the sender by return e-mail and delete this message from your system. Any unauthorized use or dissemination of this message in whole or in part is strictly prohibited. Please note that e-mails are susceptible to change. RxStrategies, Inc. shall not be liable for the improper or incomplete transmission of the information contained in this communication or for any delay in its receipt or damage to your system. RxStrategies, Inc. does not guarantee that the integrity of this communication has been maintained nor that this communication is free from viruses, interceptions or interference.