devxlogo

Improve Performance by Reducing Column Size

Improve Performance by Reducing Column Size

During design time, you generally allocate some space to the columns by default. When it comes to tweaking performance, you may try to go back to the design and reduce column size in order to save memory space. This method is just not possible in most tables that contain data. Here’s a trick for reducing column size:

 DESC EMPLOYEE Name                            Null?    Type ------------------------------- -------- ---- EMPNO                           NOT NULL NUMBER(4) ENAME                                    VARCHAR2(100) JOB                                      VARCHAR2(10) MGRID                                    NUMBER(4) JOINDATE                                 DATE DEPTID                                   NUMBER(2)

The following code reduces the size of the column ENAME from 100 to 50.

drop table TEMP_TABLE;create table TEMP_TABLE as select rowid rowid_xx, ENAME from EMPLOYEE;create index TEMP_TABLE on TEMP_TABLE (rowid_xx);alter table EMPLOYEE modify (ENAME NULL);update      EMPLOYEE    set  ENAME = NULL;alter table EMPLOYEE modify (ENAME VARCHAR2(50));update      EMPLOYEE    set  ENAME = (     select ENAME from TEMP_TABLE where rowid_xx = EMPLOYEE.rowid);drop table TEMP_TABLE;
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist