calculating size of a table - Page 2
DBAsupport.com Forums - Powered by vBulletin
Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: calculating size of a table

  1. #11
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Quote Originally Posted by Vipassana
    I think you have added more confusion
    I think it's about time you finaly do some reading of oracle documentation, in particular The Concepts Manual.

    Untill you don't have at least a slightest idea what each of your two queries are doing and untill you don't know some of the very basic Oracle database vocabulary, any further explanation will only add more confusion. But nevertheless, I'll try to address some of your questions:

    First of all which is which? I presume the first statement means "how much space is needed to store all those rows" and the second means "the other is how much space is actually allocated by that table".
    I'll leave this for your homework - I hope you'll managed to find out which of your two queries is doing what.

    What does "all the rows" mean here?
    It means all the rows that are currently in your PRODUCT table. It means NUM_ROWS from your first query.

    And also what does "how much space is needed..." mean?
    It means how much space do you need in the table to store those NUM_ROWS rows in it. Your query reported that you need approximately 14 Kb free space to store those rows in your table. So, if your create a new table to be 14Kb in size that would probably be sufficient to insert those rows in it. If you create your new table to be 64Kb, you'll be fine too - when you insert those rows that you currently have in your PRODUCT table, they will occupy about 14KB of your new table, leaving 50Kb free space in it. But if you create your new table to be 10Kb large, without the ability for it to dinamicaly add new extents, you won't be able to insert all of the rows from your PRODUCT table in it, because they require 14Kb (according to your formula), but you only have 10Kb free space in it.

    Thridly I didn't understand what you meant by "the other is how much space is actually allocated by that table". You mean how is actually used? If so "used out of what (how much)?"
    As I said, take a look at the Concepts manual and read about "blocks" and "segments" and "extents", about "data files" and "tablespaces". It will all become so clear......
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  2. #12
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,684
    OK. Let's make this simple. The lack of detail in this answer is intentional!

    Consider this:

    You insert 1,000,000 rows into a new table, causing it to increase in size so it can hold all the rows. At the end of this load process the table is 1M in size. It's safe to say that it takes 1M to store 1,000,000 rows.

    You then decide to delete 999,999 rows, leaving a single row in the table. The table has not shrunk so it is still 1M in size, but obviously has lots of emty space in it. Can we use the same logic as before to make a conclusion? No. If we did we would be saying that it takes 1M to store 1 row. That's obviously nonsense.

    So what?

    Well, measuring the size of a table by summing all the blocks or bytes gives you the size of the table, not the size of the data it is holding.

    Estimating the size of the data based on num_rows and avg_row_length gives you an idea of the size of the data, not the current size of the table holding it.

    What next?

    Decide what you actually want to know:

    - The size of the table currently.
    - The size of the data in the table.
    - Something else.

    Cheers

    Tim...
    Tim...
    OCP DBA 7.3, 8, 8i, 9i, 10g, 11g
    OCA PL/SQL Developer
    Oracle ACE Director
    My website: www.oracle-base.com
    My blog: www.oracle-base.com/blog

  3. #13
    Join Date
    Jan 2001
    Posts
    2,828
    Hi Tim

    I really really admire your patience :-D

    regards
    Hrishy

  4. #14
    Join Date
    Jan 2001
    Posts
    2,828
    Hi

    Oops i should be calling you rather Prof Tim

    regards
    Hrishy

  5. #15
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,684
    Quote Originally Posted by hrishy
    Hi Tim

    I really really admire your patience :-D

    regards
    Hrishy
    You wouldn't say that if you ever worked with me. I can be a right ....


    Quote Originally Posted by hrishy
    Hi

    Oops i should be calling you rather Prof Tim

    regards
    Hrishy
    Where did that come from?
    Tim...
    OCP DBA 7.3, 8, 8i, 9i, 10g, 11g
    OCA PL/SQL Developer
    Oracle ACE Director
    My website: www.oracle-base.com
    My blog: www.oracle-base.com/blog

  6. #16
    Join Date
    Jul 2003
    Posts
    134
    Hmmm lots of details. Good, now atleast I am clear that I lack certain basic fundamentals. Will give it a reading... and get back if I still have some clarifications. Thanks for all your time and patience guys.

  7. #17
    Join Date
    Jan 2001
    Posts
    2,828
    Quote Originally Posted by TimHall
    You wouldn't say that if you ever worked with me. I can be a right ....




    Where did that come from?

    Well thats becoz you had all the patience in the world to explain to the students here :-) Prof Tim

  8. #18
    Join Date
    Jul 2007
    Posts
    1

    Unhappy URGENT: Table size in 9i

    Hi,

    the query

    select sum(bytes) from user_segments where segment_name = 'tablename'; is giving sum(bytes) as blank, not even a zero. Please help. Does the user need dba permission to run this query?

    Please reply asap.

    Thanks and regards,
    rcm

  9. #19
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,554
    did you actually type the tablename in lowercase?
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width