Force order applies to where condition?

Force order applies to where condition?

Post by Quentin Ra » Tue, 10 Dec 2002 23:07:07



Hi,

assume I have the following query:

select * from Customer c
inner join Phone p
on p.custId = c.custId
where p.PhoneNo = '1234567'
and p.PhoneNoAreaCd = '890'
force order

does the force order hint also applies to the sequence of the where
condition?  As a simplified example the impact of force order on the order
of the table is not necessarily justified here.  But my question is about
its effect on the where conditions.  Thanks for your looking into this.

Quentin

 
 
 

Force order applies to where condition?

Post by Gert-Jan Stri » Tue, 10 Dec 2002 23:22:52


From BOL:

FORCE ORDER
Specifies that the join order indicated by the query syntax is preserved
during query optimization

Based on this description, it does not necessarily affect the WHERE
clause.

If you want to test it, and you are running SQL2K, then you can create a
UDF that does some logging, and transform your statement into:

select ...
where dbo.MyUDF(p.PhoneNo)='1234567'
and   dbo.MyUDF(p.PhoneNoAreaCd)='890'
option (force order)

Gert-Jan


> Hi,

> assume I have the following query:

> select * from Customer c
> inner join Phone p
> on p.custId = c.custId
> where p.PhoneNo = '1234567'
> and p.PhoneNoAreaCd = '890'
> force order

> does the force order hint also applies to the sequence of the where
> condition?  As a simplified example the impact of force order on the order
> of the table is not necessarily justified here.  But my question is about
> its effect on the where conditions.  Thanks for your looking into this.

> Quentin


 
 
 

1. Applying Conditions to a View (SQL 7)

Hello,

I am designing a new view in SQL 7 Enterprise Manager. I have a column
called CRDistance which shows how far a hotel is from a city.  It is a
simple number. E.g.: 3 (meaning 3 miles from a city).

What I would like is to create a condition in that column to where if
CRDistance = 0, then write "in", otherwise, write the number. I would
appreciate any help someone could give me on this one.  Thanks,

Chris

2. SQL Problem

3. SELECT MAX only if condition applies!

4. US-VA-FUNCTIONAL FINANCIAL ANALYZER CONSULTANT (REF number : HL-244)

5. Forcing optimize to evaluate only one side of OR-condition

6. Repairing an Access database using JRO

7. RECOVER question : how to force to apply logs from a clean but old database back-up

8. Brain Death

9. Error: Sort Order Cannot Be Applied

10. SQL Puzzle - Applying calculations to running balances in a specified order

11. Sort order cannot be applied (80040e60)

12. applied logs out of order