Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6830399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:36:47+00:00 2026-05-26T22:36:47+00:00

At work, I have a large table (some 3 million rows, like 40-50 columns).

  • 0

At work, I have a large table (some 3 million rows, like 40-50 columns). I sometimes need to empty some of the columns and fill them with new data. What I did not expect is that

UPDATE table1 SET y = null

takes much more time than filling the column with data which is generated, for example, in the sql query from other columns of the same table or queried from other tables in a subquery. It does not matter if I go through all table rows at once (like in the update query above) or if I use a cursor to go through the table row by row (using the pk). It does not matter if I use the large table at work or if I create a small test table and fill it with some hundredthousands of test-rows. Setting the column to null always takes way longer (Throughout the tests, I encountered factors of 2 to 10) than updating the column with some dynamic data (which is different for each row).

Whats the reason for this? What does Oracle do when setting a column to null? Or – what’s is my error in reasoning?

Thanks for your help!

P.S.: I am using oracle 11g2, and found these results using both plsql developer and oracle sql developer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:36:48+00:00Added an answer on May 26, 2026 at 10:36 pm

    Summary

    I think updating to null is slower because Oracle (incorrectly) tries to take advantage of the way it stores nulls, causing it to frequently re-organize the rows in the block (“heap block compress”), creating a lot of extra UNDO and REDO.

    What’s so special about null?

    From the Oracle Database Concepts:

    “Nulls are stored in the database if they fall between columns with data values. In these cases they require 1 byte to store the length of the column (zero).

    Trailing nulls in a row require no storage because a new row header signals that the remaining columns in the previous row are null. For example, if the last three columns of a table are null, no information is stored for those columns. In tables with many columns,
    the columns more likely to contain nulls should be defined last to conserve disk space.”

    Test

    Benchmarking updates is very difficult because the true cost of an update cannot be measured just from the update statement. For example, log switches will
    not happen with every update, and delayed block cleanout will happen later. To accurately test an update, there should be multiple runs,
    objects should be recreated for each run, and the high and low values should be discarded.

    For simplicity the script below does not throw out high and low results, and only tests a table with a single column. But the problem still occurs regardless of the number of columns, their data, and which column is updated.

    I used the RunStats utility from http://www.oracle-developer.net/utilities.php to compare the resource consumption of updating-to-a-value with updating-to-a-null.

    create table test1(col1 number);
    
    BEGIN
        dbms_output.enable(1000000);
    
       runstats_pkg.rs_start;
    
        for i in 1 .. 10 loop
            execute immediate 'drop table test1 purge';
            execute immediate 'create table test1 (col1 number)';
            execute immediate 'insert /*+ append */ into test1 select 1 col1
                from dual connect by level <= 100000';
            commit;
            execute immediate 'update test1 set col1 = 1';
            commit;
        end loop;
    
       runstats_pkg.rs_pause;
       runstats_pkg.rs_resume;
    
        for i in 1 .. 10 loop
            execute immediate 'drop table test1 purge';
            execute immediate 'create table test1 (col1 number)';
            execute immediate 'insert /*+ append */ into test1 select 1 col1
                from dual connect by level <= 100000';
            commit;
            execute immediate 'update test1 set col1 = null';
            commit;
        end loop;
    
       runstats_pkg.rs_stop();
    END;
    /
    

    Result

    There are dozens of differences, these are the four I think are most relevant:

    Type  Name                                 Run1         Run2         Diff
    ----- ---------------------------- ------------ ------------ ------------
    TIMER elapsed time (hsecs)                1,269        4,738        3,469
    STAT  heap block compress                     1        2,028        2,027
    STAT  undo change vector size        55,855,008  181,387,456  125,532,448
    STAT  redo size                     133,260,596  581,641,084  448,380,488
    

    Solutions?

    The only possible solution I can think of is to enable table compression. The trailing-null storage trick doesn’t happen for compressed tables.
    So even though the “heap block compress” number gets even higher for Run2, from 2028 to 23208, I guess it doesn’t actually do anything.
    The redo, undo, and elapsed time between the two runs is almost identical with table compression enabled.

    However, there are lots of potential downsides to table compression. Updating to a null will run much faster, but every other update will run at least slightly slower.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Do you guys have some tips to make any large table, with 500+ rows,
I have some large files (images and video) which I need to store in
I have a requirement to find rows in a table containing 200,000 entries. Some
Here at work we have a very large application with multiple sub applications. (500
I have a fairly large PHP codebase (10k files) that I work with using
In my experience I have only had 2 patterns work for large-scale desktop application
In software companies I have seen it's really hard to work on very large
I have a large table consisting of over 60 millions records and I would
I have a large table with with each cell being 25x25 and a div
So I am using jQuery and I have a rather large table for what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.