0

I have created View using unioned CVAS:

CREATE
OR REPLACE VIEW SAMPLEVIEW AS
SELECT
  PT.CREDITPARTYACCOUNT AS PT_CREDITPARTYACCOUNT,
  PT.DEBITPARTYACCOUNT AS PT_DEBITPARTYACCOUNT,
...
...
FROM
  accountingevent AE
  LEFT OUTER JOIN paymenttransaction PT ON (
    AE.PAYMENTTRANSACTIONKEY = PT.PAYMENTTRANSACTIONKEY
  )
  OR (
    AE.PAYMENTINSTRUCTIONKEY = PT.INCOMINGINSTRUCTIONKEY
  )
WHERE
  ...
UNION ALL
SELECT
  PT.CREDITPARTYACCOUNT AS PT_CREDITPARTYACCOUNT,
  PT.DEBITPARTYACCOUNT AS PT_DEBITPARTYACCOUNT,
...
...
FROM
  accountingevent AE
  LEFT OUTER JOIN paymenttransaction PT ON (
    AE.PAYMENTTRANSACTIONKEY = PT.PAYMENTTRANSACTIONKEY
  )
WHERE
    ...
ORDER BY 1;

Result of

DESC SAMPLEVIEW;
PT_CREDITPARTYACCOUNT   VARCHAR2(1024 CHAR)
PT_DEBITPARTYACCOUNT    VARCHAR2(1024 CHAR)
...
...

AND

DESC PAYMENTTRANSACTION;
CREDITPARTYACCOUNT  VARCHAR2(256 CHAR)
DEBITPARTYACCOUNT   VARCHAR2(256 CHAR)
...

Data Sizes I get are 4 times the size of table column sizes. If we remove the UNION ALL and go with single CVAS than sizes becomes equal in table and view. This view and tables are part of large scripts so something in scripts is off which is causing this behavior. This odd behavior is only visible with char and varchar2 datatypes. I also checked the result of the following query:

select * from NLS_DATABASE_PARAMETERS where parameter='NLS_CHARACTERSET';
NLS_CHARACTERSET    AL32UTF8

Kindly guide me on what could be wrong here which is causing this behavior.

Thanks

coming out of void
  • 1,454
  • 2
  • 12
  • 12

1 Answers1

0

Which version are you testing? Here's what I get on my DB (20.2):

SQL> desc tukc
Name        Null? Type               
----------- ----- ------------------ 
OBJECT_NAME       VARCHAR2(128 CHAR) 
OBJECT_ID         NUMBER             
SQL> 
SQL> create or replace view tv as
  2  select t.object_name
  3  from tukc t join all_objects o on (t.object_id=o.object_id)
  4  union all
  5  select t.object_name
  6  from tukc t join all_objects o on (t.object_id=o.object_id)
  7  ;

View TV created.

SQL> desc tv
Name        Null? Type               
----------- ----- ------------------ 
OBJECT_NAME       VARCHAR2(128 CHAR) 
gsalem
  • 1,957
  • 1
  • 8
  • 7