Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using Pipeline Table functions with other tables

bobmaganSep 18 2013 — edited Sep 20 2013

I am on DB 11.2.0.2 and have sparingly used pipelined table functions but am considering it for a project that has some fairly big (lots of rows) sized tables. In my tests, selecting from just the pipelined table perform pretty well (whether it is directly from the pipleined table or the view I created on top of it). Where I start to see some degregation when I try to join the pipelined tabe view to other tables and add where conditions.

ie:

SELECT A.empno, A.empname, A.job, B.sal

FROM EMP_VIEW A, EMP B

WHERE A.empno = B.empno AND

      B.mgr = '7839'

I have seen some articles and blogs that mention this as a cardinality issue, and offer some undocumented methods to try and combat.

Can someone please give me some advice or tips on this. Thanks!

I have created a simple example using the emp table below to help illustrate what I am doing.

DROP TYPE EMP_TYPE;

DROP TYPE EMP_SEQ;

CREATE OR REPLACE TYPE EMP_SEQ AS OBJECT

       ( EMPNO                                         NUMBER(10),

         ENAME                                         VARCHAR2(100),

         JOB                                           VARCHAR2(100));

/

CREATE OR REPLACE TYPE EMP_TYPE AS TABLE OF EMP_SEQ;

/

CREATE OR REPLACE FUNCTION get_emp return EMP_TYPE PIPELINED AS

BEGIN

  FOR cur IN (SELECT

                empno,

                ename,

                job

              FROM emp

         )

         LOOP

           PIPE ROW(EMP_SEQ(cur.empno,

                            cur.ename,

                            cur.job));

         END LOOP;

         RETURN;

END get_emp;

     

create OR REPLACE view EMP_VIEW as select * from table(get_emp());

/  

SELECT A.empno, A.empname, A.job, B.sal

FROM EMP_VIEW A, EMP B

WHERE A.empno = B.empno AND

      B.mgr = '7839'

This post has been answered by Billy Verreynne on Sep 19 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 18 2013
Added on Sep 18 2013
14 comments
1,048 views