Skip to Main Content
  • Questions
  • when are empty/partially empty blocks used

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, rachelle.

Asked: July 01, 2012 - 11:42 pm UTC

Last updated: July 03, 2012 - 5:43 pm UTC

Version: 10g and above

Viewed 1000+ times

You Asked

Hi Tom,

Can you explain how are blocks populated during an insert?
To be more specific, say I have a table that was initially populated, and then some random data are deleted. Then I would have an empty/partially empty block in between ie.
UUUUUfUUUUUFFFF

When will the partially used block "f" be populated so it will turn into "U" ?

Thanks.

and Tom said...

It might be used right away, it might be used a few inserts later, it might never be reused.

It depends.


I'm going to assume bitmap managed free space here (ASSM - automatic segment space management). Here - when you go to insert, we need to find a block with sufficient free space. These blocks - the blocks allocated to your table under the high water mark - are managed on bitmap freelists. We'll walk through those in a semi hap-hazzard manner (we try to spread inserts out over many blocks to avoid concurrent insert concurrency issues). When we find a space to put it - we'll put it there. We don't go for a specific block, we go for a block with sufficient free space and that hopefully no one else is working on.

You might get lucky and reuse that block right away.

It might take a few inserts to get around to it.

If the table is very dynamic - lots of deletes + inserts - we might not get around to using it again - if ever. the table wouldn't grow or anything, we just might not need it.


We will tend to use that block however before we grab more blocks to put under the high water mark. So the table won't grow if there are free blocks under the high water mark.

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

How to check for non-empty blocks ?

José Laurindo Chiappa, July 03, 2012 - 2:56 pm UTC

In a related point : find / show quantity of totally empty blocks is easy, and it´s easy, too, dump a block and check for empty slots, but how about check for quantity of blocks only x% filled ? Example, I want to know how many blocks (in a given tablespace, say) are currently less than 50% filled ?
The objective here is confirm the effectiveness of block reuse algorithms, don´t ending with a large quantity of blocks half-used not being inserted, what could defy the usefulness of block cache ...

Regards,

J. Laurindo Chiappa


Tom Kyte
July 03, 2012 - 5:43 pm UTC

search this site for "show_space"

it does that using supplied plsql packages.

Thanks for taking time to respond

Rachelle, July 03, 2012 - 6:35 pm UTC

Simple but well explained. Thanks, Tom!