Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 performance problem when i write "where 1=1"?

Author  Topic 

beliveinmyshelf
Starting Member

15 Posts

Posted - 2009-05-08 : 07:38:32
have a query "select * from scott where 1=1". i want to know does this query have performance problem in case scott had 10000 rows?

Tran Manh Linh - Linhtm
linhtm.viss@gmail.com
linhtm@vietintelligences.com

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-05-08 : 07:54:39
No. The executionplan shows: it is the same.

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-05-08 : 08:18:42
quote:
Originally posted by beliveinmyshelf

have a query "select * from scott where 1=1". i want to know does this query have performance problem in case scott had 10000 rows?

Tran Manh Linh - Linhtm
linhtm.viss@gmail.com
linhtm@vietintelligences.com


It is same as using
select * from scott

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

beliveinmyshelf
Starting Member

15 Posts

Posted - 2009-05-08 : 08:20:31
how many rows in table you used to test?
is these query you use :
"select * from scott" and "select * from scott where 1=1"

Tran Manh Linh - Linhtm
linhtm.viss@gmail.com
linhtm@vietintelligences.com
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-05-08 : 09:11:32
I used a table with 12542 rows.
I used that query select * from tablename and select * from tablename where 1=1 but with another tablename.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -