RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: SQL
Expertise: Advanced
Sep 21, 2005

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:


 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;
MS Sridhar
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date