You main issue is the row length.
It may or may not be a problem.
In Oracle
, trailing NULL
columns consume no space.
If your first 2
columns are non-NULL
and other 168
are NULL
's, then the row will occupy only the space required for the first 2
columns.
But if the 1
-st and the 170
-th columns are both non-NULL
, then all space required for 170
columns needs to be reserved.
When performing FULL TABLE SCAN
, you will have to read more data blocks. This is better than a JOIN
if you need all columns, but worse in you need only some of them.
If you rarely need some columns, you better create a separate CLUSTERED
table for them and use the JOIN
's.
Note that by a CLUSTERED
table Oracle
means not what others mean.
In Oracle
, a clustered table means creating two or more tables that share a common key they will be joined on.
When placing the table rows into the tablespace, Oracle
will place rows with same values of the key into same datablocks. This vastly increases the speed of JOIN
's.
This looks like this:
CREATE CLUSTER data_of_170_columns (id NUMBER(10))
/
CREATE TABLE main_data_of_3_columns CLUSTER data_of_170_columns(id) (id NUMBER(10) NOT NULL PRIMARY KEY, col2 VARCHAR2(20) NOT NULL, col3 VARCHAR2(50) NOT NULL)
/
CREATE TABLE secondary_data_of_167_columns CLUSTER data_of_170_columns(id) (id NUMBER(10) NOT NULL PRIMARY KEY, col4 VARCHAR2(100) NULL, …)
/
From both tables, the rows with the same id
will reside in same datablock or close to it, and this query:
SELECT *
FROM main_data_of_3_columns d3, secondary_data_of_167_columns d167
WHERE d3.id = d167.id
will be almost as efficient as selecting from a single large table, while this one:
SELECT *
FROM main_data_of_3_columns d3
will be faster than selecting from a single large table.