SlideShare a Scribd company logo
ORACLE TABLES
   Juri Guljajev
WHAT WILL WE TALK ABOUT?
                              External


                             Temporary
Tables
              Relational
                           Heap organized
                             (“normal”)
               Object
                           Index organized
                                (IOT)
LITTLE THEORY - HOW DATABASE STORE DATA?
• Smallest unit of data in Oracle is data block.
• Default size of data block is 8 kilobytes.
• Normally only one table rows can be added into one data block
• Database tries to store the whole row in one block

                                Customer id = 1
                                Customer id = 2

     CUSTOMER                   Data block
LITTLE THEORY                -      ROWID
ROWID looks like AAAAaoAATAAABrXAAA
OOOOOOFFFBBBBBBRRR
• OOOOOO: The data object number that identifies the
  database segment (AAAAao in the example).
• FFF: The tablespace-relative datafile number of the datafile
  that contains the row (file AAT in the example).
• BBBBBB: The data block that contains the row
  (block AAABrX in the example).
• RRR: The row in the block. (AAA in the example)
LITTLE THEORY - INDEX IN HEAP TABLE
 Index is using ROWID to point on data from table.

 SELECT * FROM customer WHERE id = 1;
HEAP ORGANISED             -       KEY FEATURES
• Unordered collection of rows
• Retrieval order is not guaranteed
• Rows are inserted where they fit best
• Generally better DML performance (in compare to IOT)
• Worse query performance by PK (in compare to IOT)
• Can be stored in table cluster
HEAP ORGANIZED              -      PCTFREE
The PCTFREE parameter sets the minimum percentage
of a data block to be reserved as free space for possible
updates to rows that already exist in that block.
                                            FREE
  CREATE TABLE test
       ( id NUMBER)                       Data block
                                         PCTFREE 10
  PCTFREE 10;
HEAP ORGANISED                -   PCTFREE
                   INSERT (example)
• 1 row size is: 5 bytes + 1900 bytes = 1905 bytes
• PCTFREE 10: (8192B – 10%) / 1905B = 3 rows

                     FREE
                                    FREE


                   PCTFREE 10     PCTFREE 50

                     3 rows         2 rows
HEAP ORGANISED                 -      PCTFREE
                       UPDATE (example)
 Rows, that can’t fit into block after update were moved to
 new data block and references were left in old data block.
 ROWID of migrated row is not changed.
                                    OLD BLOCK           NEW BLOCK
         PCTFREE 10
UPDATE                 UPDATE       Ref left here ROW
           First row
                                    PCTFREE 10          PCTFREE 10
           updated
                                                        1 row from old
            3 rows                                          block
                                     2 rows left
HEAP ORGANISED           -     PCTFREE
                      UPDATE
Table, that have PCTFREE 50 have enough storage room
to fit added data into the same data block.


           FREE

                                 PCTFREE 50
         PCTFREE 50   UPDATE
                                   2 rows
           2 rows
HEAP ORGANISED            -      PCTFREE
• Better query performance
• Better storage usage
• Use with caution (set PCTFREE 50, but rows are filled
  by 80% with insert)
HEAP/INDEX ORGANISED              -        PARTITIONING
Partitioning helps to improve performance with high data
volumes and allows DBAs to manage data in more
convenient way.


                                      Partition 1
                                      Partition 2

         Non-partitioned table   Partitioned table


                                      Partition n
HEAP/INDEX ORGANISED               -    PARTITIONING
Table can be partitioned by
• Range (for historical data, often partitioned by date
  column)
• Hash (no obvious partitioning column)
• List (to group data specifically by some known values)


Range and List partitions may have subpartitions.
HEAP/INDEX ORGANISED   -   PARTITIONING
HEAP/INDEX ORGANISED                  -     PARTITIONING
Indexes on partitioned table can be global or local partitioned.
• Local
   • Maps on table partitions, so easier to maintain
   • Unique index can be local, but partitioning key must be
     part of index
• Global
   • Has own partitions definitions
   • Can be partitioned by range or hash
INDEX ORGANISED             -    KEY FEATURES
• Stored in a variation of a B-tree index structure
• Primary key stores all rows
• Fast access by primary key (specially range scan)
• DML performance might be worse (in compare to
  HEAP)
• Take less room on disk (no separate primary key
  storage required)
• Cannot be stored in table cluster
INDEX ORGANISED   -   KEY FEATURES
INDEX ORGANISED            -     KEY FEATURES
PROS
• Fast access by PK
• Less storage for the same amount of data
• Data is ordered by PK
CONS
• Slower DML
• Secondary index can be slower and take more storage in
  compare to index in HEAP table
TABLE CLUSTER
Group of tables that share common columns and store
related data in the same blocks.


                              IP_RESTRICTION
                                 customer_id
        CUSTOMER
        customer_id
                             TIME_RESTRICTION
                                 customer_id
TABLE CLUSTER
SELECT* FROM customer WHERE customer_id = :id;


SELECT * FROM ip_restriction JOIN time_restriction
USING(customer_id) WHERE customer_id = :id;


SELECT * FROM customer JOIN ip_restriction
USING(customer_id) JOIN time_restriction
USING(customer_id) WHERE customer_id = :id;
TABLE CLUSTER
In cluster single data block contains rows from several
clustered tables.

          clustered                       unclustered

                                      customer
           customer
            customer
             customer                              time_retstr.
                                      ip_retstr.
TABLE CLUSTER
And all data, that contains the same clustered key value
are stored together.
                          unclustered
      CUSTOMER_ID FIRST_NAME      LAST_NAME   …
      1             AAA           BBB
      2             CCC           DDD

      CUSTOMER_ID   IP             CUSTOMER_ID    TIME
      1             192.168.1.1    1              MON 8-18
      1             192.168.1.2    1              WEN 10-15
      2             68.1.1.1       2              MON 8-18
TABLE CLUSTER
And all data, that contains the same clustered key value
are stored together.
                           clustered
       CUSTOMER_ID FIRST_NAME    LAST_NAME   …
       1           AAA           BBB
                   IP
                   192.168.1.1
                   192.168.1.2
                   TIME
                   MON 8-18
       2           CCC           DDD
TABLE CLUSTER
What you will get
• Disk I/O is reduced for joins of clustered tables.
• Access time improves for joins of clustered tables.
• Less storage is required to store related table and index data because
   the cluster key value is not stored repeatedly for each row.
But be careful (do not use when)
• The tables are frequently updated.
• The tables frequently require a full table scans.
• The tables require truncating.
TABLE CLUSTER
There are 2 types of clusters
Index cluster
• Data is co-located within a single block based on a common
  column index, so separate cluster index should be created
  before adding table into cluster
Hash cluster
• Data is co-located within a single block based on a hash
  key and a hash function (own hash function can be used)
TABLE CLUSTER
Index VS Hash clusters
• Hash is faster
• Hash take less storage
• For hash you should know number of hash keys
• Hash cluster size and keys number can’t be changed
• Hash cluster loads CPU more, than index cluster
Юра Гуляев. Oracle tables

More Related Content

What's hot (19)

PDF
Advanced MySQL Query Optimizations
Dave Stokes
 
PPTX
MySQL Replication Evolution -- Confoo Montreal 2017
Dave Stokes
 
PPTX
Dbms & oracle
J VijayaRaghavan
 
PDF
Efficient Pagination Using MySQL
Evan Weaver
 
PDF
MySQL Query And Index Tuning
Manikanda kumar
 
PDF
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
Norvald Ryeng
 
PDF
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Jaime Crespo
 
PDF
Techday2010 Postgresql9
Dan-Claudiu Dragoș
 
PPTX
Lazy beats Smart and Fast
Julian Hyde
 
PDF
Plmce 14 be a_hero_16x9_final
Marco Tusa
 
PDF
Performance improvements in PostgreSQL 9.5 and beyond
Tomas Vondra
 
DOCX
DataBase Management System Lab File
Uttam Singh Chaudhary
 
PPTX
Oracle Database 12.1.0.2 New Features
Alex Zaballa
 
PDF
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
MariaDB plc
 
PDF
PostgreSQL performance improvements in 9.5 and 9.6
Tomas Vondra
 
PDF
[Www.pkbulk.blogspot.com]dbms13
AnusAhmad
 
PDF
Introduction to MySQL Query Tuning for Dev[Op]s
Sveta Smirnova
 
PDF
MySQL Optimizer Cost Model
Olav Sandstå
 
PPTX
DBMS information in detail || Dbms (lab) ppt
gourav kottawar
 
Advanced MySQL Query Optimizations
Dave Stokes
 
MySQL Replication Evolution -- Confoo Montreal 2017
Dave Stokes
 
Dbms & oracle
J VijayaRaghavan
 
Efficient Pagination Using MySQL
Evan Weaver
 
MySQL Query And Index Tuning
Manikanda kumar
 
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
Norvald Ryeng
 
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Jaime Crespo
 
Techday2010 Postgresql9
Dan-Claudiu Dragoș
 
Lazy beats Smart and Fast
Julian Hyde
 
Plmce 14 be a_hero_16x9_final
Marco Tusa
 
Performance improvements in PostgreSQL 9.5 and beyond
Tomas Vondra
 
DataBase Management System Lab File
Uttam Singh Chaudhary
 
Oracle Database 12.1.0.2 New Features
Alex Zaballa
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
MariaDB plc
 
PostgreSQL performance improvements in 9.5 and 9.6
Tomas Vondra
 
[Www.pkbulk.blogspot.com]dbms13
AnusAhmad
 
Introduction to MySQL Query Tuning for Dev[Op]s
Sveta Smirnova
 
MySQL Optimizer Cost Model
Olav Sandstå
 
DBMS information in detail || Dbms (lab) ppt
gourav kottawar
 

Similar to Юра Гуляев. Oracle tables (20)

PPTX
Database tables
HasanUYANIK2
 
PPT
Unit 4 data storage and querying
Ravindran Kannan
 
PPTX
DBMS (UNIT 5)
Dr. SURBHI SAROHA
 
PDF
[INSIGHT OUT 2011] B26 optimising a two table join(jonathan lewis)
Insight Technology, Inc.
 
PPT
Data Indexing Presentation-My.pptppt.ppt
sdsm2
 
PPTX
Getting to know oracle database objects iot, mviews, clusters and more…
Aaron Shilo
 
PPT
Five Tuning Tips For Your Datawarehouse
Jeff Moss
 
PDF
Cassandra at Morningstar (Feb 2011)
jeremiahdjordan
 
PPTX
Geek Sync | The Universe of Oracle Indexing
IDERA Software
 
PDF
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdf
InSync2011
 
PPT
Stack It And Unpack It
Jeff Moss
 
PDF
Indexing techniques
Huda Alameen
 
PPTX
Geek Sync | Tips for Data Warehouses and Other Very Large Databases
IDERA Software
 
PPTX
File Organization in database management.pptx
ubaidullah75790
 
PDF
Indexing Strategies for Oracle Databases - Beyond the Create Index Statement
Sean Scott
 
PPTX
Practical MS SQL Introduction
Naji El Kotob
 
PPTX
lecture 2 notes indexing in application of database systems.pptx
peter1097
 
PPTX
normalization process in relational data base management
ssuserf80a8c
 
PPT
Unit08 dbms
arnold 7490
 
PPTX
SQL Server 2014 Memory Optimised Tables - Advanced
Tony Rogerson
 
Database tables
HasanUYANIK2
 
Unit 4 data storage and querying
Ravindran Kannan
 
DBMS (UNIT 5)
Dr. SURBHI SAROHA
 
[INSIGHT OUT 2011] B26 optimising a two table join(jonathan lewis)
Insight Technology, Inc.
 
Data Indexing Presentation-My.pptppt.ppt
sdsm2
 
Getting to know oracle database objects iot, mviews, clusters and more…
Aaron Shilo
 
Five Tuning Tips For Your Datawarehouse
Jeff Moss
 
Cassandra at Morningstar (Feb 2011)
jeremiahdjordan
 
Geek Sync | The Universe of Oracle Indexing
IDERA Software
 
Database & Technology 1 _ Tom Kyte _ SQL Techniques.pdf
InSync2011
 
Stack It And Unpack It
Jeff Moss
 
Indexing techniques
Huda Alameen
 
Geek Sync | Tips for Data Warehouses and Other Very Large Databases
IDERA Software
 
File Organization in database management.pptx
ubaidullah75790
 
Indexing Strategies for Oracle Databases - Beyond the Create Index Statement
Sean Scott
 
Practical MS SQL Introduction
Naji El Kotob
 
lecture 2 notes indexing in application of database systems.pptx
peter1097
 
normalization process in relational data base management
ssuserf80a8c
 
Unit08 dbms
arnold 7490
 
SQL Server 2014 Memory Optimised Tables - Advanced
Tony Rogerson
 
Ad

Recently uploaded (20)

PDF
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
Ad

Юра Гуляев. Oracle tables

  • 1. ORACLE TABLES Juri Guljajev
  • 2. WHAT WILL WE TALK ABOUT? External Temporary Tables Relational Heap organized (“normal”) Object Index organized (IOT)
  • 3. LITTLE THEORY - HOW DATABASE STORE DATA? • Smallest unit of data in Oracle is data block. • Default size of data block is 8 kilobytes. • Normally only one table rows can be added into one data block • Database tries to store the whole row in one block Customer id = 1 Customer id = 2 CUSTOMER Data block
  • 4. LITTLE THEORY - ROWID ROWID looks like AAAAaoAATAAABrXAAA OOOOOOFFFBBBBBBRRR • OOOOOO: The data object number that identifies the database segment (AAAAao in the example). • FFF: The tablespace-relative datafile number of the datafile that contains the row (file AAT in the example). • BBBBBB: The data block that contains the row (block AAABrX in the example). • RRR: The row in the block. (AAA in the example)
  • 5. LITTLE THEORY - INDEX IN HEAP TABLE Index is using ROWID to point on data from table. SELECT * FROM customer WHERE id = 1;
  • 6. HEAP ORGANISED - KEY FEATURES • Unordered collection of rows • Retrieval order is not guaranteed • Rows are inserted where they fit best • Generally better DML performance (in compare to IOT) • Worse query performance by PK (in compare to IOT) • Can be stored in table cluster
  • 7. HEAP ORGANIZED - PCTFREE The PCTFREE parameter sets the minimum percentage of a data block to be reserved as free space for possible updates to rows that already exist in that block. FREE CREATE TABLE test ( id NUMBER) Data block PCTFREE 10 PCTFREE 10;
  • 8. HEAP ORGANISED - PCTFREE INSERT (example) • 1 row size is: 5 bytes + 1900 bytes = 1905 bytes • PCTFREE 10: (8192B – 10%) / 1905B = 3 rows FREE FREE PCTFREE 10 PCTFREE 50 3 rows 2 rows
  • 9. HEAP ORGANISED - PCTFREE UPDATE (example) Rows, that can’t fit into block after update were moved to new data block and references were left in old data block. ROWID of migrated row is not changed. OLD BLOCK NEW BLOCK PCTFREE 10 UPDATE UPDATE Ref left here ROW First row PCTFREE 10 PCTFREE 10 updated 1 row from old 3 rows block 2 rows left
  • 10. HEAP ORGANISED - PCTFREE UPDATE Table, that have PCTFREE 50 have enough storage room to fit added data into the same data block. FREE PCTFREE 50 PCTFREE 50 UPDATE 2 rows 2 rows
  • 11. HEAP ORGANISED - PCTFREE • Better query performance • Better storage usage • Use with caution (set PCTFREE 50, but rows are filled by 80% with insert)
  • 12. HEAP/INDEX ORGANISED - PARTITIONING Partitioning helps to improve performance with high data volumes and allows DBAs to manage data in more convenient way. Partition 1 Partition 2 Non-partitioned table Partitioned table Partition n
  • 13. HEAP/INDEX ORGANISED - PARTITIONING Table can be partitioned by • Range (for historical data, often partitioned by date column) • Hash (no obvious partitioning column) • List (to group data specifically by some known values) Range and List partitions may have subpartitions.
  • 14. HEAP/INDEX ORGANISED - PARTITIONING
  • 15. HEAP/INDEX ORGANISED - PARTITIONING Indexes on partitioned table can be global or local partitioned. • Local • Maps on table partitions, so easier to maintain • Unique index can be local, but partitioning key must be part of index • Global • Has own partitions definitions • Can be partitioned by range or hash
  • 16. INDEX ORGANISED - KEY FEATURES • Stored in a variation of a B-tree index structure • Primary key stores all rows • Fast access by primary key (specially range scan) • DML performance might be worse (in compare to HEAP) • Take less room on disk (no separate primary key storage required) • Cannot be stored in table cluster
  • 17. INDEX ORGANISED - KEY FEATURES
  • 18. INDEX ORGANISED - KEY FEATURES PROS • Fast access by PK • Less storage for the same amount of data • Data is ordered by PK CONS • Slower DML • Secondary index can be slower and take more storage in compare to index in HEAP table
  • 19. TABLE CLUSTER Group of tables that share common columns and store related data in the same blocks. IP_RESTRICTION customer_id CUSTOMER customer_id TIME_RESTRICTION customer_id
  • 20. TABLE CLUSTER SELECT* FROM customer WHERE customer_id = :id; SELECT * FROM ip_restriction JOIN time_restriction USING(customer_id) WHERE customer_id = :id; SELECT * FROM customer JOIN ip_restriction USING(customer_id) JOIN time_restriction USING(customer_id) WHERE customer_id = :id;
  • 21. TABLE CLUSTER In cluster single data block contains rows from several clustered tables. clustered unclustered customer customer customer customer time_retstr. ip_retstr.
  • 22. TABLE CLUSTER And all data, that contains the same clustered key value are stored together. unclustered CUSTOMER_ID FIRST_NAME LAST_NAME … 1 AAA BBB 2 CCC DDD CUSTOMER_ID IP CUSTOMER_ID TIME 1 192.168.1.1 1 MON 8-18 1 192.168.1.2 1 WEN 10-15 2 68.1.1.1 2 MON 8-18
  • 23. TABLE CLUSTER And all data, that contains the same clustered key value are stored together. clustered CUSTOMER_ID FIRST_NAME LAST_NAME … 1 AAA BBB IP 192.168.1.1 192.168.1.2 TIME MON 8-18 2 CCC DDD
  • 24. TABLE CLUSTER What you will get • Disk I/O is reduced for joins of clustered tables. • Access time improves for joins of clustered tables. • Less storage is required to store related table and index data because the cluster key value is not stored repeatedly for each row. But be careful (do not use when) • The tables are frequently updated. • The tables frequently require a full table scans. • The tables require truncating.
  • 25. TABLE CLUSTER There are 2 types of clusters Index cluster • Data is co-located within a single block based on a common column index, so separate cluster index should be created before adding table into cluster Hash cluster • Data is co-located within a single block based on a hash key and a hash function (own hash function can be used)
  • 26. TABLE CLUSTER Index VS Hash clusters • Hash is faster • Hash take less storage • For hash you should know number of hash keys • Hash cluster size and keys number can’t be changed • Hash cluster loads CPU more, than index cluster