09-18-2008 11:47 AM
Hi All,
I have a small confusion.
Consider these 3 statements :
A.
SELECT * from table1 where {conditions based on primary key}.
exit.
Endselect.
B.
SELECT SINGLE * from table1 where {conditions based on primary key}.
C.
SELECT upto 1 rows from table1 where {conditions based on primary key}.
Considering that table1 has more than 1 primary keys,Which statement gives the best peformance when
1.All the keys are used in the where condition.
2.Only a few keys are used in the where condition
Thanks in advance.
Hari
09-18-2008 11:54 AM
09-18-2008 11:57 AM
Hi,
If you are interested in only one record then
1.All the keys are used in the where condition.
Ans B
2.Only a few keys are used in the where condition
Ans C
santhosh
09-18-2008 11:58 AM
hi
in all cases option B will give best performance.
first option will give very poor performance
(checked)
09-18-2008 11:58 AM
In situation 1 it's definitly B. In situation 2 I would say "a mix of C and A", like:
SELECT field1 ... fieldn from table1 UP TO 1 ROWS where {conditions based on primary key}.
exit.
Endselect.
Regards,
Valter Oliveira.