Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: ARRAYSIZE??? --> Glogin.sql
Hi, from Oracles metalink site ....
SQL*Plus: 'BUFFER OVERFLOW' Explained
SQL> SELECT * FROM dept;
buffer overflow. Use SET command to reduce ARRAYSIZE or increase
MAXDATA.
How the Overflow Occurs:
To set MAXDATA, use the SET MAXDATA command in SQL*Plus.
Calculating the Buffer Size:
There may be space wasted because of calls to the align() function to align pointers along word boundaries. This is dynamic and cannot be predetermined. As a result, there may be a discrepancy between the value at which the "buffer overflow" message actually disappears and the value returned by the formula.
Examples:
Example 1: Using the demo DEPT table
Name Null? Type ------------------------------- -------- ---- DEPTNO NOT NULL NUMBER(2) DNAME CHAR(14) LOC CHAR(13)
Calculations:
For deptno: n=20, d=10, h=6, t=4, and the value according to the
formula is 477.
For dname: n=20, d=14, h=5, t=4, and the value is 559.
For loc: n=20, d=13, h=3, t=4, and the value is 534.
Add these up: 477 + 559 + 534 = 1570
SQL> SET MAXDATA 1569;
SQL> SELECT * FROM dept;
buffer overflow. Use SET command to reduce ARRAYSIZE or increase
MAXDATA.
SQL> SET MAXDATA 1570;
SQL> SELECT * FROM dept;
DEPTNO DNAME LOC
Name Null? Type ------------------------------- -------- ---- COL1 NUMBER(7) COL2 CHAR(10) COL3 DATE For COL1: n=20, d=10, h=4, t=4, and the value is 473.For COL2: n=20, d=10, h=4, t=4, and the value is 473. For COL3: n=20, d= 9, h=4, t=4, and the value is 452.
Add these up: 473 + 473 + 452 = 1398
SQL> SET MAXDATA 1399;
SQL> SELECT * FROM test;
buffer overflow. Use SET command to reduce ARRAYSIZE or increase
MAXDATA.
SQL> SET MAXDATA 1400;
SQL> SELECT * FROM test;
COL1 COL2 COL3
If you are selecting columns from different tables by joining them on a Primary/Foreign key, use the tablename for the column of which it is the primary key.
Glossary:
is the memory space in bytes that SQL*Plus presents to the kernel. This memory space is utilized by the kernel to send in the rows requested by the user through the SELECT statement. ARRAYSIZE is the number of rows that SQL*Plus will fetch from the database table at one time and put in the buffer. Valid values are 1 to 5000. A large value increases the efficiency of queries and subqueries that fetch many rows because a large number of rows are being filled into the buffer space. This gain in efficiency is hardly realized for the arraysize of over 100. Please note that ARRAYSIZE has no effect on the SQL*Plus operations other than increasing the efficiency of the query, and it is not related to the number of rows that the SQL SELECT actually brings back. MAXDATA sets the maximum total row width that the SQL*Plus can process. The default and the maximum values of MAXDATA varies from operating system to operating system. It is 500 through 60000 in VMS; it is 500 through 32767 for UNIX systems. The total row width depends on the arraysize. BUFFER SIZE FORMULA The formula, for the size of the BUFFER (Memory Usage), when reduced, appears as follows: Memory usage = 7n + n*d + d + 2h + t + 111 in bytes where: n = ARRAYSIZE (number of rows) d = column width in the output of SQL*Plus (the display length) h = column heading length t = table name length These computations are for 32-bit platforms only. 'd', the display width, can best be determined by counting the number of dashes that makes the underline of the column headings. Note that this length has nothing to do with the column specification given at the time of the creation of the table. If "COLUMN .. FORMAT" command is used to format a column, that length should be taken into account. 'h', the column heading length, is the number of characters in the column heading. For ENAME, it is 5; for DEPTNO, it is 6. 't' is the table name length. For DEPT, it is 4; for EMP, it is 3.
HTH NEILC Jaqueline Berghout wrote:
> > Thank you very much Reiner. > > It works!!! (it is so simple.... but I couldn't find it out myself) > > Do you knwo when I have to set a ARRAYSIZE into 500 or 5? > I mean, why and when??? > > And what has MAXDATA to do with it. Is there an relation between ARRAYSIZE > and MAXDATA? > > Thank you > JaquelineReceived on Wed Dec 22 1999 - 09:15:30 CST