Subject Re: [firebird-support] About conditions in SQL query.
Author Thomas Miller
I disagree, the order does matter. If there is no index, then the order
matters a lot.
I don't know enough about FB optimizer, in Oracle, the order is taken in
account
by the optimizer when choosing between two paths (for instance two indexes
that may have these columns in it.)

When you write SQL statements, you always want to put the most significant
qualifiers first in the where clause. The optimizer may over rule this,
but it is
a good practice.

Martijn Tonies wrote:
> Hi,
>
>
>> I have a question about the order in 'WHERE' statement
>> in SQL queries. If I have:
>>
>> 1)
>> select * from SOME_TABLE
>> where (OBJECT_ID=100)
>> and (ACTIVE=1)
>>
>> FB searchs first for OBJECT_ID matches and then for
>> ACTIVE in the results?
>>
>> 2)
>> select * from SOME_TABLE
>> where (ACTIVE=1)
>> and (OBJECT_ID=100)
>>
>> FB searchs first for ACTIVE matches and then for
>> OBJECT_ID in the results?
>> -----------------------
>>
>> or the order of conditions in WHERE does not matter to
>> FB?
>>
>
> Indeed, it doesn't matter. Firebird will decide what to do
> first, depending on conditions like "is there an index available
> for a column".
>
> Martijn Tonies
> Database Workbench - development tool for InterBase and more!
> Upscene Productions
> http://www.upscene.com
> My thoughts:
> http://blog.upscene.com/martijn/
> Database development questions? Check the forum!
> http://www.databasedevelopmentforum.com
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net 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
>
>
>
>
>
>
>
>
>

--
Thomas Miller
Chrome Portal Project Manager
Wash DC Delphi SIG Chairperson
Delphi Client/Server Certified Developer
BSS Accounting & Distribution Software
BSS Enterprise Accounting FrameWork

http://www.bss-software.com
http://www.cpcug.org/user/delphi/index.html
http://sourceforge.net/projects/chromeportal/
http://sourceforge.net/projects/uopl/
http://sourceforge.net/projects/dbexpressplus