0

I'd like to know what would have a better concurrency level, VARRAY or nested tables. Is it really true that VARRAY only need one input/output operation ot load the collection?

It's for a reservations systems.

Regards,

MT0
  • 143,790
  • 11
  • 59
  • 117
llinasenc
  • 11
  • 1
  • 2
    You might get a more detailed answer if you explain what you mean when you ask about "Concurrency Level" as most databases (including Oracle) have ACID properties which means that there is [atomicity in transactions](https://docs.oracle.com/cd/E11882_01/server.112/e40540/transact.htm#CNCPT016). When you are asking about I/O operations are you asking at the transaction level (i.e. DML statements) or are you asking about disk I/O? – MT0 Oct 09 '19 at 11:49
  • Hi, I'm asking about transaction level. Sorry for not being enough clear. – llinasenc Oct 09 '19 at 16:20

1 Answers1

0

Is it really true that VARRAY only need one input/output operation ot load the collection?

Define a VARRAY and a collection type:

CREATE TYPE test_varray AS VARRAY(3) OF NUMBER;
CREATE TYPE test_collection AS TABLE OF NUMBER;

Then you can create similar tables for each of those data types:

CREATE TABLE test1 (
  id    NUMBER PRIMARY KEY,
  array test_varray
);

CREATE TABLE test2 (
  id    NUMBER PRIMARY KEY,
  array test_collection
) NESTED TABLE array STORE AS test2__array;

You can INSERT into those tables as a single statement:

INSERT INTO test1 ( id, array ) VALUES ( 1, test_varray( 1.1, 1.2, 1.3 ) );
INSERT INTO test2 ( id, array ) VALUES ( 1, test_collection( 1.1, 1.2, 1.3 ) );

You can SELECT from those tables as a single statement:

SELECT id, column_value FROM test1 CROSS JOIN TABLE( array );
SELECT id, column_value FROM test2 CROSS JOIN TABLE( array );

Which both output:

ID | COLUMN_VALUE
-: | -----------:
 1 |          1.1
 1 |          1.2
 1 |          1.3

db<>fiddle here

So from a point of INSERT/SELECT operations they are functionally similar. The Oracle Documentation - Understanding PL/SQL Collection Types explains some of the differences mainly:

  • VARRAY has a bounded number of elements and is always dense.
  • Collections (Nested Tables) can have an unbounded number of elements and could be sparse.
MT0
  • 143,790
  • 11
  • 59
  • 117