stored procedure. select from a table with partition column.

Database
Tourist

stored procedure. select from a table with partition column.

Hi all.

I do some select from a table with partition column (mrgn_id):

CREATE MULTISET TABLE rai_test AS (
                    SELECT na.*
                    FROM N_ACTV na
                    WHERE 1=1
                    AND MRGN_ID=0
                    ) WITH DATA NO PRIMARY INDEX;

Explain:

We do an all-AMPs RETRIEVE step from 1919 partitions of N_ACTV

 

When this code is stored in procedure:

REPLACE PROCEDURE  rai_test_part (PROC_MR BYTEINT) SQL SECURITY INVOKER
BEGIN
    CREATE MULTISET TABLE rai_test AS (
                   SELECT na.*
                    FROM N_ACTV na
                    WHERE 1=1
                    AND MRGN_ID=:PROC_MR                   
                    ) WITH DATA NO PRIMARY INDEX;
END;

 

Optimizer all-rows scans.

 

Why is this happening?