Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: table operator on table of rowids
Hello Chris,
"Chris Bateman" <chrisbateman_at_despammed.com> wrote in message
news:70a27038b2c06a9b31ef965ffa52c766_at_news.teranews.com...
> "VC" <boston103_at_hotmail.com> wrote in message
> an admittedly crude performance test of 4 methods:
>
> 1. A 'control' test, where I build a PL/SQL table of numbers and then cast
> it to select by the primary key of the table.
>
> (By using rowids instead, performance should improve a little by avoiding
a
> table access to get the primary key value and then an index scan to get
the
> rowid from primary key).
>
> 2. Jonathan's 'array_as_cursor' style function improves on the control
test
> by approx 10%.
>
> 3. VC's DBMS_ROWID method was 60% slower than my control test - perhaps
due
> to the numerous function calls involved or use of PL/SQL table of
> object_type?
>
> 4. Using a PL/SQL table of varchar2(18) is 20% faster than my control
test.
> I guess this works because my varchar2 rowid value is implicitly cast to
> rowid type...
>
> SQL> select * from foobar where rowid = 'AAAG4yAAGAAAAAMAAt';
>
> Execution Plan
> ----------------------------------------------------------
> 0 SELECT STATEMENT Optimizer=CHOOSE
> 1 0 TABLE ACCESS (BY USER ROWID) OF 'FOOBAR'
>
> I'm going to go with the last method because it's simple and fast.
>
> Regards
> Chris
>
>
Using varchar2 to store rowids is actually a cute idea. I ran some benchmarks and it turns out that you assumption abouthe functions I used being slower than conversion to varchar2 is true:
Case 1:
l_RID myRIDTable := myRIDTable();
begin
call count cpu elapsed disk query current
rows
------- ------ -------- ---------- ---------- ---------- ---------- ------
...
select * from t1 where
rowid in (select DBMS_ROWID.ROWID_CREATE ( rowid_type, object_number, relative_fno, block_number, row_number) from table(cast(:b1 as myRIDTable))) call count cpu elapsed disk query currentrows
Case 2
l_RID myRIDTable2 := myRIDTable2();
begin
-- for x in (select * from t1 where rowid in (select * from table(cast(l_RID as myRIDTable2))) )loop null; end loop;
call count cpu elapsed disk query current
rows
------- ------ -------- ---------- ---------- ---------- ---------- ------
select * from t1 where
rowid in (select * from table(cast(:b1 as myRIDTable2)))
call count cpu elapsed disk query current
rows
------- ------ -------- ---------- ---------- ---------- ---------- ------
The last select is almost three times faster with varchar2 than with the function calls.
The only hitch may be future de-support by Oracle of this rowid<->varchar2 conversion.
Rgds.
VC Received on Wed Feb 04 2004 - 18:16:01 CST
![]() |
![]() |