Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Left Join on 2 Integers, 1 Float, or 1 Char
I have 2 tables in Oracle 8i. One has 500,000 records (Table A), the other 5 million (Table B). I have to left join them on two integers. Which of the following will have the best performance (fastest select)? Or is there another option?
Option 1: Join on 2 integer fields
SELECT A.*, B.*
FROM A, B
WHERE A.INTEGER1 = B.INTEGER1(+) AND A.INTEGER2 = B.INTEGER2(+) AND A.INTEGER1 = 1234 AND A.INTEGER2 = 89
Option 2: Create a floating point field combining the two integers and join on it.
SELECT A.*, B.*
FROM A, B
WHERE A.FLOAT1 = B.FLOAT1(+)
AND A.FLOAT1 = 1234.89
Option 3: Create a char or varchar2 field combining the two integers and
join on it.
SELECT A.*, B.*
FROM A, B
WHERE A.CHAR1 = B.CHAR1(+)
AND A.CHAR1 = '1234-89'
Thanks,
Dan Received on Mon May 14 2001 - 19:27:46 CDT