Home>Question Details



jian huang -- Thanks for the question regarding "How does insert and delete use space regarding to indexes?", version 9.2.0

Submitted on 6-Jan-2009 7:33 Central time zone
Last updated 13-Mar-2009 7:28

You Asked

Hello Tom

I have such as test:
SQL> create table t as select * from dba_objects;

Table created.

SQL> desc t
Name

OWNER
OBJECT_NAME
SUBOBJECT_NAME
OBJECT_ID
DATA_OBJECT_ID
OBJECT_TYPE
CREATED
LAST_DDL_TIME
TIMESTAMP
STATUS
TEMPORARY
GENERATED
SECONDARY

SQL> create index t_ind on t(object_id);

Index created.

SQL> desc segment_space_a
PROCEDURE segment_space_a
Argument Name            Type            In/Out Default?
------------------------------ ----------------------- ------ --------
P_SEGNAME              VARCHAR2          IN
P_OWNER                VARCHAR2          IN  DEFAULT
P_TYPE                VARCHAR2          IN  DEFAULT
P_PARTITION            VARCHAR2          IN  DEFAULT

SQL> set serveroutput on size 1000000
SQL> exec segment_space_a(P_SEGNAME=>'T_IND',p_type=>'INDEX');
Unformatted Blocks .....................          0
FS1 Blocks (0-25) .....................          0
FS2 Blocks (25-50) .....................          1
FS3 Blocks (50-75) .....................          0
FS4 Blocks (75-100).....................          0
Full Blocks    .....................        65
Total Blocks............................        80
Total Bytes.............................      655,360
Total MBytes............................          0
Unused Blocks...........................          7
Unused Bytes............................      57,344
Last Used Ext FileId....................        14
Last Used Ext BlockId...................        120
Last Used Block.........................          1

PL/SQL procedure successfully completed.

SQL> delete from t;

29599 rows deleted.

SQL> exec segment_space_a(P_SEGNAME=>'T_IND',p_type=>'INDEX');
Unformatted Blocks .....................          0
FS1 Blocks (0-25) .....................          0
FS2 Blocks (25-50) .....................        66
FS3 Blocks (50-75) .....................          0
FS4 Blocks (75-100).....................          0
Full Blocks    .....................          0
Total Blocks............................        80
Total Bytes.............................      655,360
Total MBytes............................          0
Unused Blocks...........................          7
Unused Bytes............................      57,344
Last Used Ext FileId....................        14
Last Used Ext BlockId...................        120
Last Used Block.........................          1

PL/SQL procedure successfully completed.

SQL> insert into t select * from dba_objects;

29600 rows created.

SQL> exec segment_space_a(P_SEGNAME=>'T_IND',p_type=>'INDEX');
Unformatted Blocks .....................        76
FS1 Blocks (0-25) .....................          0
FS2 Blocks (25-50) .....................        102
FS3 Blocks (50-75) .....................          0
FS4 Blocks (75-100).....................          0
Full Blocks    .....................        128
Total Blocks............................        384
Total Bytes.............................    3,145,728
Total MBytes............................          3
Unused Blocks...........................        64
Unused Bytes............................      524,288
Last Used Ext FileId....................        14
Last Used Ext BlockId...................        776
Last Used Block.........................        64

PL/SQL procedure successfully completed.

SQL>

First I create a table t and index it. then I check the index blocks to see the space consumed.
Then I delete all rows from T and check the index block and as expected , the blocks remain the same... But when I reinsert the *same* rows, I expect the deleted spaces to be reused, since index data has its own place to go and rows are same. but you can see that the blocks increase by almost 55 percent.

Why is that? Since the same rows are inserted ?

Thanks!

and we said...

space in an index cannot be reused in the SAME transaction. If you:


delete from t;
1,000,000 rows deleted
insert into t select * from t2;
1,000,000 rows inserted

you would expect to see the indexes effectively double in size. If on the other hand you:

delete from t;
1,000,000 rows deleted
COMMIT;
insert into t select * from t2;
1,000,000 rows inserted


then you would find the index to probably be about the same size - the space would be reused.


Now, if the job was to remove all rows and reload the table, I would recommend:
truncate t;
insert /*+ APPEND */ into t select * from t2;


That would result in the most efficient space utilization. If you cannot have the data "disappear" (eg, this reload must be transactional) you can use partitioning, for example assume you want to reload T from a staging table:

drop table t;
drop table stage;
create table stage as select * from all_objects;

create table t
(
part_id,
OWNER, OBJECT_NAME, SUBOBJECT_NAME, OBJECT_ID, DATA_OBJECT_ID, OBJECT_TYPE, CREATED,
LAST_DDL_TIME, TIMESTAMP, STATUS, TEMPORARY, GENERATED, SECONDARY
)
NOLOGGING
PARTITION BY list (part_id)
(
  PARTITION part1 VALUES (1),
  PARTITION part2 VALUES (2)
)
as 
select 1, stage.* 
  from stage;

create index t_idx on t(owner,object_type,object_name) local nologging;

create or replace procedure refresh_t
as
    l_empty   number;
    l_full    number;
begin
    /* figure out partition to insert into, that'll be the EMPTY one */
    select empty, full into l_empty, l_full
      from (
    select 2 empty, 1 full
      from t partition (part1) 
     where rownum=1 
     union all 
    select 1 empty, 2 full
      from t partition (part2)
     where rownum=1
           );
    insert /*+ APPEND */ into t
    select l_empty, stage.* 
      from stage;

    execute immediate 'alter table t truncate partition part' || to_char(l_full);
end;
/



that'll have space utilized as nicely as possible. Only one partition at a time will appear to have data as far as end users are concerned.
Reviews    
5 stars   January 7, 2009 - 4am Central time zone
Reviewer: A reader 
Richard Foote has write a note about index which says the following.

When a index entry is marked as deleted and a subsequent insert occurs in the same block where the 
deleted entry reside then oracle automatically cleans up the deleted entry. 

The note is here

http://richardfoote.wordpress.com/2008/06/18/deleted-index-entries-part-ii-v-2-schneider/

A resent post in OTN forum by him also says the same

http://forums.oracle.com/forums/message.jspa?messageID=3197213#3197213

My question would be, the OP has first created the table with dba_objects and after performing the 
delete on the table he once again inserted the same data that is from dba_object. So, will not all 
or at least most of the existing blocks containing the deleted entry be revisited during the 
insert, And hence forth cleaning up most of the deleted entries?

Have i understood the concept explained by Richard Foote in a wrong way. Please correct me.

Thanks,
Karthick.


Followup   January 7, 2009 - 9am Central time zone:

deleted index space *cannot* be reused in a single transaction.

If you throw a commit in there - then it can (and will) be reused.

consider:

ops$tkyte%ORA9IR2> create table t as select * from all_objects;

Table created.

ops$tkyte%ORA9IR2>
ops$tkyte%ORA9IR2> create index t_idx on t(object_name);

Index created.

ops$tkyte%ORA9IR2> analyze index t_idx validate structure;

Index analyzed.

ops$tkyte%ORA9IR2>
ops$tkyte%ORA9IR2> select name, blocks, lf_blks, br_blks, lf_rows, del_lf_rows, br_rows from 
index_stats;

NAME      BLOCKS    LF_BLKS    BR_BLKS    LF_ROWS DEL_LF_ROWS    BR_ROWS
----- ---------- ---------- ---------- ---------- ----------- ----------
T_IDX        256        149          1      30691           0        148

ops$tkyte%ORA9IR2>
ops$tkyte%ORA9IR2> delete from t;

30691 rows deleted.

ops$tkyte%ORA9IR2> COMMIT;

Commit complete.

ops$tkyte%ORA9IR2> insert into t select * from all_objects;

30692 rows created.

ops$tkyte%ORA9IR2> COMMIT;

Commit complete.

ops$tkyte%ORA9IR2>
ops$tkyte%ORA9IR2> analyze index t_idx validate structure;

Index analyzed.

ops$tkyte%ORA9IR2> select name, blocks, lf_blks, br_blks, lf_rows, del_lf_rows, br_rows from 
index_stats;

NAME      BLOCKS    LF_BLKS    BR_BLKS    LF_ROWS DEL_LF_ROWS    BR_ROWS
----- ---------- ---------- ---------- ---------- ----------- ----------
T_IDX        256        149          1      30692           0        148

ops$tkyte%ORA9IR2>
ops$tkyte%ORA9IR2> delete from t;

30692 rows deleted.

ops$tkyte%ORA9IR2> insert into t select * from all_objects;

30692 rows created.

ops$tkyte%ORA9IR2> COMMIT;

Commit complete.

ops$tkyte%ORA9IR2>
ops$tkyte%ORA9IR2> analyze index t_idx validate structure;

Index analyzed.

ops$tkyte%ORA9IR2> select name, blocks, lf_blks, br_blks, lf_rows, del_lf_rows, br_rows from 
index_stats;

NAME      BLOCKS    LF_BLKS    BR_BLKS    LF_ROWS DEL_LF_ROWS    BR_ROWS
----- ---------- ---------- ---------- ---------- ----------- ----------
T_IDX        384        310          1      61384       30692        309





it is all about the fact that index space cannot be reused in the same transaction that freed it

5 stars Thanks!   January 7, 2009 - 12pm Central time zone
Reviewer: jian huang zheng 
Nice explaination, Thanks!


5 stars   January 8, 2009 - 2am Central time zone
Reviewer: Richard Foote from Australia
Yes, a deleted index entry will not be cleaned out within the same transaction.

However, note that with a UNIQUE index, a deleted entry can be subsequently reused if re-inserted 
within the same transaction.

So with the orginal OP index on object_id, if it was created as a Unique index, and the deleted / 
insert applied, you would find the index size would remain the same.

Cheers
Richard Foote
http://richardfoote.wordpress.com/


Followup   January 8, 2009 - 9am Central time zone:

Richard -

thanks much for the followup tweak :)
4 stars Confused   February 11, 2009 - 10am Central time zone
Reviewer: Narendra from UK
Hello Tom/Richard,

I am bit confused here. In this post, you have demonstrated above that index space is not reused within the same transaction (in 9i). But in a very old review (
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2424495760219#5404349841171
),
you have demonstrated how the deleted space is reused (in 8i). That example seems to achieve space-reuse within the same transaction.
Can you please help me in understanding the same ?

Followup   February 11, 2009 - 1pm Central time zone:

I see commits all over that example you pointed to - why do you think it was the same transaction, be more specific
2 stars Example   February 12, 2009 - 4am Central time zone
Reviewer: Narendra from UK
Tom,

Here is a copy-paste of the example I was talking about

You can test your theories about the empno 1-10 easily on your own systems -- give it a whirl. The
easiest way to bust a myth is to give a counter case! I'll do this one for you:


ops$tkyte@ORA817DEV.US.ORACLE.COM> create table emp ( empno int constraint emp_pk primary key,
ename varchar2(30) );
Table created.

ops$tkyte@ORA817DEV.US.ORACLE.COM> insert into emp select rownum, username from all_users;
46 rows created.

ops$tkyte@ORA817DEV.US.ORACLE.COM> analyze index emp_pk validate structure;
Index analyzed.

ops$tkyte@ORA817DEV.US.ORACLE.COM> select lf_rows, del_lf_rows from index_stats;

  LF_ROWS DEL_LF_ROWS
---------- -----------
    46      0

that shows there are 46 leaf row entries -- 46 index entries

ops$tkyte@ORA817DEV.US.ORACLE.COM> delete from emp where empno <= 10;
10 rows deleted.

ops$tkyte@ORA817DEV.US.ORACLE.COM>
ops$tkyte@ORA817DEV.US.ORACLE.COM> analyze index emp_pk validate structure;
Index analyzed.

ops$tkyte@ORA817DEV.US.ORACLE.COM> select lf_rows, del_lf_rows from index_stats;

  LF_ROWS DEL_LF_ROWS
---------- -----------
    46      10

That shows there are still 46 entries HOWEVER, 10 of them happened to be "deleted" -- not
pointing to an active row in the table anymore...


ops$tkyte@ORA817DEV.US.ORACLE.COM> insert into emp select rownum, lower(username) from all_users
where rownum <= 10;

10 rows created.

ops$tkyte@ORA817DEV.US.ORACLE.COM> analyze index emp_pk validate structure;

Index analyzed.

ops$tkyte@ORA817DEV.US.ORACLE.COM> select lf_rows, del_lf_rows from index_stats;

  LF_ROWS DEL_LF_ROWS
---------- -----------
    46      0

Lo and behold, there are still only 46 leaf block entries (rows) and now there are 0 deleted
ones. That proves that we'll reuse space. Just to make it more interesting, we'll do the same
thing but we'll reuse the entries WITH DIFFERENT values (not 1..10)


Followup   February 12, 2009 - 12pm Central time zone:

well two things

a) a unique index can reuse space within the same transaction (that was just mentioned right above - Richard Foote comment)

b) analyze is ddl, ddl commits - the analyze are commits.

ops$tkyte%ORA11GR1> create table t ( x int constraint t_pk primary key );

Table created.

ops$tkyte%ORA11GR1> insert into t values ( 1 );

1 row created.

ops$tkyte%ORA11GR1> analyze index t_pk validate structure;

Index analyzed.

ops$tkyte%ORA11GR1> rollback;

Rollback complete.

ops$tkyte%ORA11GR1> select * from t;

         X
----------
         1



if analyze didn't commit, the rollback would undo the insert.
4 stars Thanks   February 13, 2009 - 4am Central time zone
Reviewer: Narendra from UK
Thanks Tom.
I missed out both the aspects, unique & analyze as DDL.


5 stars   February 27, 2009 - 3am Central time zone
Reviewer: Michael Virnstein 
Hi Tom,

when i have a table, where i frequently delete and insert lots of rows and this table has a primary 
key populated by a sequence, will the deleteted space be reused on that primary key index, when new 
rows get inserted or will it just grow? I see lots of DEL_LF_ROWS in that index.
Is an reverse key index a good solution for such a primary key index to reuse space?

Regards, Michael


Followup   March 3, 2009 - 9am Central time zone:

do you delete MOST but not ALL of the old rows? If so, you might need to coalesce that index.


do you delete large range of contigous rows? for example: where id between 100 and 10000. Then the index will take care of itself over time. You would expect to see deleted leaf rows after a delete, but the subsequent inserts will cause fully empty leaf blocks to move over from the left to the right and get reused over time.
4 stars   March 3, 2009 - 12pm Central time zone
Reviewer: Michael Virnstein 
Thanks for your answer, tom.

> do you delete MOST but not ALL of the old rows? If so, you might need to coalesce that index.

we do not delete all of the rows and we don't delete ranges. The pks of the rows involved are quite random, so i would have to go with the coalesce. This approach isn't possible at the moment, because we are using standard edition of 10g. I also wouldn't want to coalesce periodically. I read some of your posts regarding index rebuilding, where you said to better fix the problem once and not maintaining something over and over.
As i don't need to query the index with "pk > :x" or "max(pk)", i thought a reverse index would probably be a solution, because it would result in a more even data distribution and deleted space would be reused more quickly than waiting that an index block will be empty completely.
Is there something wrong with my approach?

Followup   March 3, 2009 - 9pm Central time zone:

given your constraints, it would be something to definitely consider - yes.
3 stars Index "Leaking" with regular DELETEs and INSERTs   March 4, 2009 - 1am Central time zone
Reviewer: Hemant K Chitale from Singapore
In a Peoplesoft application, I have a table which udergoes periodic DELETEs (ie in batch jobs / 
process requests) :
"DELETE FROM PS_COMB_EXP_TAO4 WHERE PROCESS_INSTANCE >= 0",
followed by an INSERT.
Every INSERT is then followed by a COMMIT.
(Agreed, that there may be no COMMIT between the DELETE and the INSERT and, since the two Indexes 
are not Unique, index leaf blocks may not be reused by the same transaction ... but the *next* 
transaction should be able to re-use the blocks ?)

However, I find that the Index segment keeps growing. Even queries (from a seperate session) also 
show very high consistent gets when using the Index :

SQL> set autotrace on
SQL> select count(*) from sysadm.ps_comb_exp_tao4 where process_instance > 0;
COUNT(*)
----------
0
Execution Plan
----------------------------------------------------------
0
SELECT STATEMENT Optimizer=ALL_ROWS (Cost=3 Card=1 Bytes=4)
1 0
SORT (AGGREGATE)
2 1
INDEX (FAST FULL SCAN) OF 'PSACOMB_EXP_TAO4' (INDEX) (Cost=3 Card=500 Bytes=2000)
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
6775 consistent gets
6401 physical reads
0 redo size
335 bytes sent via SQL*Net to client
427 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed

SQL> select /*+ FULL (c) */ count(*) from sysadm.ps_comb_exp_tao4 c;
COUNT(*)
----------
0
Execution Plan
----------------------------------------------------------
0
SELECT STATEMENT Optimizer=ALL_ROWS (Cost=4 Card=1)
1 0
SORT (AGGREGATE)
2 1
TABLE ACCESS (FULL) OF 'PS_COMB_EXP_TAO4' (TABLE) (Cost=4 Card=500)
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
137 consistent gets
0 physical reads
0 redo size
335 bytes sent via SQL*Net to client
427 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed


The optimizer is, unfortunately, using the Index for even executing the DELETEs.  Since such 
DELETEs happen frequently through the day, from standard Peoplesoft code, I need to find why the 
Index keeps growing.
COALESCE/REBUILD would "fix" the issue but would have to be scheduled as an additional job.

(The current Execution Plan shows a CARD of 500 as that is from the "Locked" Statistics on the 
table).


Followup   March 4, 2009 - 1pm Central time zone:

table create
index create
more information on the number of rows deleted/added over time.


why are the statistics so bad on this? It cost the fast full scan at 3, the table scan at 4. If the index is BIGGER than the table, that would be 'wrong'. Are the statistics even remotely "correct" for this stuff?
2 stars Information about the table and "leaking" index   March 5, 2009 - 1am Central time zone
Reviewer: Hemant K Chitale from Singapore
SQL> desc sysadm.ps_comb_exp_tao4
 Name                                                                     Null?    Type
 ------------------------------------------------------------------------ -------- 
--------------------------
 PROCESS_INSTANCE                                                         NOT NULL NUMBER(10)
 SETID                                                                    NOT NULL VARCHAR2(5)
 TREE_EFFDT                                                                        DATE
 PROCESS_GROUP                                                            NOT NULL VARCHAR2(10)
 COMBINATION                                                              NOT NULL VARCHAR2(10)
 SEQUENCE_NBR_6                                                           NOT NULL NUMBER(38)
 CHARTFIELD                                                               NOT NULL VARCHAR2(18)
 RANGE_FROM_30                                                            NOT NULL VARCHAR2(30)
 EFFDT_FROM                                                                        DATE
 EFFDT_TO                                                                          DATE

SQL> @which_indexes
Enter value for table_name: PS_COMB_EXP_TAO4
Enter value for table_owner: SYSADM

Index                               Column                          Pos
----------------------------------- ------------------------------ ----
PSACOMB_EXP_TAO4                    PROCESS_INSTANCE                  1
                                    SETID                             2
                                    PROCESS_GROUP                     3
                                    CHARTFIELD                        4
                                    RANGE_FROM_30                     5
                                    EFFDT_FROM                        6
                                    EFFDT_TO                          7
                                    COMBINATION                       8
                                    SEQUENCE_NBR_6                    9


PSBCOMB_EXP_TAO4                    PROCESS_INSTANCE                  1
                                    SETID                             2
                                    PROCESS_GROUP                     3
                                    CHARTFIELD                        4
                                    COMBINATION                       5
                                    SEQUENCE_NBR_6                    6
                                    RANGE_FROM_30                     7
                                    EFFDT_FROM                        8
                                    EFFDT_TO                          9



18 rows selected.

SQL>

The Statistics, as I've said, have been "LOCKED" at a count of 500 rows.  The table undergoes 
INSERT and DELETE and INSERT (most likely with no COMMITs in between, only at the end of 
"processing") in sets of a few hundred to a max of 20,000 rows.

What seems strange to me is that an Index lookup has to read so very many blocks -- as if Index 
Leaf Block cleanup isn't occurring.

PROCESS_INSTANCE is the leading column of the index and every "set" of operations (DELETE INSERT) 
is for a *new* PROCESS_INSTANCE, so "older" PROCESS_INSTANCE values are not being re-used


Followup   March 5, 2009 - 1pm Central time zone:

unlock the statistics, you are doing this to yourself, we don't know what the structures look like - hence you will get 'bad' plans.


... as if Index Leaf Block cleanup isn't occurring.

...


the table is empty, until the table contains more rows, these leaf blocks have no place to go - you need fresh data in there to use them.


there are no create tables, no create indexes here. But anyway, this is happening (bad plans) because you have tricked us into thinking the index is very very very small - smaller than the table.

And right now, it isn't.


2 stars Concentrate on the Index Size   March 5, 2009 - 10pm Central time zone
Reviewer: Hemant K Chitale from Singapore
>the table is empty, until the table contains more rows, these leaf blocks have no place to go - 
you need fresh data in there to use them. 

That is why I say that the table undergoes (very many) cycles of DELETE .. INSERT .. end 
transaction.

I can understand leaf blocks not being reused between the DELETE and INSERT in 1 transaction.

But why does the next transaction still result in the index growing further.

The next transaction that runs DELETE .. INSERT .. end transaction is not cleaning up the leaf 
blocks left by the first transaction.  So, after the DELETE the INSERT in this second transaction 
allocates new leaf blocks again.

and so on for few thousand transactions every day.


My question isn't about the execution plan and I do know how the (incorrect) statistics can drive 
the wrong execution plan.   My concern here is about the index growing.




Followup   March 6, 2009 - 10am Central time zone:

Can you show us the empirical information that shows this index is growing over time?

I know it grew, but you say "it keeps growing", can you provide us a history of the growth and what happened over time (I think it has grown, and here it is, you have what you have - it is done growing, but it is currently big).

You might need to schedule a coalesce on this periodically. The delete+insert will never reuse the space and if you have more than one going on concurrently......


If you don't have the empirical information over time - coalesce or rebuild it, and start a job that monitors the growth of this segment over time (eg; every six hours, have something come in an check out the index size and save the information in a table)
5 stars why unique index can while non-unique cant?   March 7, 2009 - 11am Central time zone
Reviewer: jian huang zheng from China
Hello Tom

    I just wonder why oracle permits in a single transaction to reuse the space for the unique 
index, while non-unique just cant?
 
    what is the technical reason behind this?

     Thanks!


3 stars Index Growth Statistics   March 8, 2009 - 10pm Central time zone
Reviewer: Hemant K Chitale from Singapore
Tom,  To monitor the "growth" (or "leakage") in the Index sizes :

We had enabled collection of size information only during Overnight Batch runs (11pm to 8am).  
However, the table is also used by processes running for user requests.

Thus, I see "leakage" at different times (but no statistics captured between 8am and 11pm) :

(higlighting only the timestamps where I see an increase in the size)

SQL> l
  1  select segment_name, collection_datestamp, blocks
  2  from segments_size_history
  3  where segment_name in ('PSACOMB_EXP_TAO4','PSBCOMB_EXP_TAO4')
  4  and to_char(collection_datestamp,'DD-MON')  = '04-MAR'
  5  and (
  6  to_char(collection_datestamp,'MI') like '%2'
  7  )
  8* order by segment_name, collection_datestamp
SQL> /

SEGMENT_NAME              COLLECTION_D     BLOCKS
------------------------- ------------ ----------
PSACOMB_EXP_TAO4          04-MAR 00:02     215552

PSACOMB_EXP_TAO4          04-MAR 04:42     215552
PSACOMB_EXP_TAO4          04-MAR 04:52     215552

PSACOMB_EXP_TAO4          04-MAR 05:02     216576

PSACOMB_EXP_TAO4          04-MAR 05:12     219776
PSACOMB_EXP_TAO4          04-MAR 05:22     219776

PSACOMB_EXP_TAO4          04-MAR 05:32     223104
PSACOMB_EXP_TAO4          04-MAR 05:42     223104

PSACOMB_EXP_TAO4          04-MAR 07:02     223104
PSACOMB_EXP_TAO4          04-MAR 07:12     223104

PSACOMB_EXP_TAO4          04-MAR 23:42     264704
PSACOMB_EXP_TAO4          04-MAR 23:52     264704


PSBCOMB_EXP_TAO4          04-MAR 00:02     255232

PSBCOMB_EXP_TAO4          04-MAR 04:32     255232
PSBCOMB_EXP_TAO4          04-MAR 04:42     255232

PSBCOMB_EXP_TAO4          04-MAR 04:52     256256

PSBCOMB_EXP_TAO4          04-MAR 05:02     261120
PSBCOMB_EXP_TAO4          04-MAR 05:12     261120

PSBCOMB_EXP_TAO4          04-MAR 05:22     262144

PSBCOMB_EXP_TAO4          04-MAR 05:32     265216

PSBCOMB_EXP_TAO4          04-MAR 07:02     265216
PSBCOMB_EXP_TAO4          04-MAR 07:12     265216

PSBCOMB_EXP_TAO4          04-MAR 23:42     320128
PSBCOMB_EXP_TAO4          04-MAR 23:52     320128


SQL>


Followup   March 9, 2009 - 3am Central time zone:

this is a very short period of time, does it keep growing forever, or does it stop.


I'll have to ask again - does the delete delete everything?

how does the delete work? show the syntax of it with representative inputs

describe the column(s) this index is on - in detail. their types, their values.

does more than one session do a delete+insert at or near the same point in time.

We really need to understand all of the processing here.

2 stars Operations against the Table   March 10, 2009 - 2am Central time zone
Reviewer: Hemant K Chitale from Singapore
I have, earlier, provided the DELETE statement, the manner of usage and the Index definitions.

The DELETE always deletes *all* the rows.  

Nevertheless, here's a listing :
SQL> l
  1  select count(*), substr(sql_text,1,182), sum(executions), sum(buffer_gets), sum(cpu_time), 
sum(elapsed_time), sum(rows_processed)
  2  from v$sqlstats
  3  where upper(sql_text) like '%PS_COMB_EXP_TAO4%'
  4  and (upper(sql_text) like 'DELETE%' or upper(sql_text) like 'INSERT INTO %' )
  5  group by substr(sql_text,1,182)
  6* order by 2
SQL> /

  COUNT(*)                                                                                          
                                
----------                                                                                          
                                
SUBSTR(SQL_TEXT,1,182)                                                                              
                                
----------------------------------------------------------------------------------------------------
--------------------------------
SUM(EXECUTIONS) SUM(BUFFER_GETS) SUM(CPU_TIME) SUM(ELAPSED_TIME) SUM(ROWS_PROCESSED)                
                                
--------------- ---------------- ------------- ----------------- -------------------                
                                
         1                                                                                          
                                
DELETE FROM PS_COMB_EXP_TAO4 WHERE PROCESS_INSTANCE >= 0                                            
                                
           5414        158238699     571747534         632733408            17060606                
                                
                                                                                                    
                                
         15                                                                                         
                                 
INSERT INTO PS_COMB_EXP_TAO4 (PROCESS_INSTANCE, SETID, TREE_EFFDT, PROCESS_GROUP, COMBINATION, 
SEQUENCE_NBR_6, CHARTFIELD, RANGE_FRO
M_30, EFFDT_FROM, EFFDT_TO) SELECT 2224871, A.SETI                                                  
                                
             15               74         54876            252910                   2  
.... not listing every INSERT statement .....
--------------- ----------------               ----------------- -------------------                
                                
                                                                                                    
                                
sum                                                                                                 
                                
                                                                                                    
                                
           7367        165663154                       817821184            18600907                
                                
                                                                                                    
                                


there are 38 different INSERT statements. Each execution of an INSERT has a specific 
PROCESS_INSTANCE value -- thus an INSERT will only provide one PROCESS_INSTANCE for all the rows it 
inserts.

These operations happen concurrently between 1 to 3 sessions.


Followup   March 11, 2009 - 2am Central time zone:

...I have, earlier, provided the DELETE statement, the manner of usage and the
Index definitions.
....

and I don't page up/down/all around trying to re-find if the information was provided, this is a review/followup section - short, sweet, get tons of them every day. In between reading your snippets, I read dozens - if not hundreds - of other review/followups.

"The DELETE always deletes *all* the rows. "

and why can't we truncate?



and, this is a very short period of time, does it keep growing forever, or does it stop.


1 stars Not very helpful response   March 12, 2009 - 4am Central time zone
Reviewer: Hemant K Chitale from Singapore
> Why can't we truncate ?
Yes, I know about TRUNCATE.  I also know about REBUILD.  I also know about COALESCE.  
This is Peoplesoft (ever heard of Peoplesoft ?) delivered code.  
Yes, I have an SR with Peoplesoft and the response has been "I have searched Knowledge base and 
also if any existing bugs on theze kind of issues.There are no known issues reported for this table 
in PeopleSoft.
There are no specific inserts and deletes against this table."
which isn't helpful because I  can see Peoplesoft delivered coded doing INSERTs and DELETEs.
All I need to know is why the index size keeps growing on and on.  By more than 1GB over 20 days.

If you don't have the time to scroll up and down .... (I wonder if every asktom thread repeats 
information).
I know that a number of your supporters are going to jump on me for the title "Not very helpful 
response".  That's just too bad.  But if you offer to help someone, please put in the effort to 
help someone.


Followup   March 12, 2009 - 12pm Central time zone:

yes, I've heard of peoplesoft, did you know with peoplesoft you can sometimes write your own code, that not all code is delivered that a lot of code is developed - by you? did you know that? Do I know that you guys didn't write this code? do I? No, I do not.


Sorry you didn't find this back and forth useful. Please schedule a coalesce in the meantime - or consider unlocking the statistics.

... If you don't have the time to scroll up and down .... (I wonder if every asktom
thread repeats information).
....

if they want me to consider looking at *a REVIEW FOLLOWUP WHICH ISN"T SUPPOSED TO BE a new question* sure they do.


And you know what, if you KNOW there are deletes/inserts being done against this table, you'd be able to tell support the module that is involved and give them more information...


All I can suspect here (since I cannot reproduce myself) is that you have more concurrent "delete+inserts" happening at the same time than you believe you do - OR (just as likely) your analysis of how the table is used is flawed at some level, it doesn't happen as simply as you describe.

And no, I don't think it is horrible for me to ask you to reiterate something once or twice - you are very very close to the problem, you have all of the information. Did you hit page up and see how big this page is? How big all of the pages are? How hard it can be to scrape together the bits of data?
3 stars We'll just go ahead with REBUILDs   March 12, 2009 - 11pm Central time zone
Reviewer: Hemant K Chitale from Singapore
First, sorry I riled you.  My apologies.

I can't reproduce the "index size leakage" using a dummy table and dummy data.

Some other references are at
http://tech.groups.yahoo.com/group/psftdba/message/2533

I know the dropping or rebuilding the indexes would "fix" the issue but I coulnd't find out why the 
indexes grow. 



Followup   March 13, 2009 - 7am Central time zone:

suggest coalesces over rebuilds, rebuilds could lead easily to ora-8103's (object no longer exists) as it drops the old segment - coalesce - always online, in place operation.

unless and until we can reproduce the issue - it'll be hard to answer "why", that is what I was trying to get to (as well as suggesting things that would avoid it in the first place regardless). If we cannot simulate it using your description of what is happening - then something else is happening beyond what you are describing (we are missing part of the equation - part of the puzzle - the description of what is taking place is not 100% there yet, we have a missing fact or two). And if and when we discover that - we'll likely be able to answer "why"

Write a Review
 


All information and materials provided here are provided "as-is"; Oracle disclaims all express and implied warranties, including, the implied warranties of merchantability or fitness for a particular use. Oracle shall not be liable for any damages, including, direct, indirect, incidental, special or consequential damages for loss of profits, revenue, data or data use, incurred by you or any third party in connection with the use of this information or these materials.

About Oracle | Legal Notices and Terms of Use | Privacy Statement