SlideShare une entreprise Scribd logo
1  sur  27
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsDave Stokes
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017Dave Stokes
 
Efficient Pagination Using MySQL
Efficient Pagination Using MySQLEfficient Pagination Using MySQL
Efficient Pagination Using MySQLEvan Weaver
 
MySQL Query And Index Tuning
MySQL Query And Index TuningMySQL Query And Index Tuning
MySQL Query And Index TuningManikanda kumar
 
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZEMySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZENorvald Ryeng
 
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Jaime Crespo
 
Lazy beats Smart and Fast
Lazy beats Smart and FastLazy beats Smart and Fast
Lazy beats Smart and FastJulian Hyde
 
Plmce 14 be a_hero_16x9_final
Plmce 14 be a_hero_16x9_finalPlmce 14 be a_hero_16x9_final
Plmce 14 be a_hero_16x9_finalMarco Tusa
 
Performance improvements in PostgreSQL 9.5 and beyond
Performance improvements in PostgreSQL 9.5 and beyondPerformance improvements in PostgreSQL 9.5 and beyond
Performance improvements in PostgreSQL 9.5 and beyondTomas Vondra
 
Oracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesOracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesAlex Zaballa
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1MariaDB plc
 
PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6Tomas Vondra
 
[Www.pkbulk.blogspot.com]dbms13
[Www.pkbulk.blogspot.com]dbms13[Www.pkbulk.blogspot.com]dbms13
[Www.pkbulk.blogspot.com]dbms13AnusAhmad
 
Introduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]sIntroduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]sSveta Smirnova
 
MySQL Optimizer Cost Model
MySQL Optimizer Cost ModelMySQL Optimizer Cost Model
MySQL Optimizer Cost ModelOlav Sandstå
 
DBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) pptDBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) pptgourav kottawar
 

Tendances (19)

Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query Optimizations
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017
 
Dbms & oracle
Dbms & oracleDbms & oracle
Dbms & oracle
 
Efficient Pagination Using MySQL
Efficient Pagination Using MySQLEfficient Pagination Using MySQL
Efficient Pagination Using MySQL
 
MySQL Query And Index Tuning
MySQL Query And Index TuningMySQL Query And Index Tuning
MySQL Query And Index Tuning
 
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZEMySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
MySQL 8.0.18 latest updates: Hash join and EXPLAIN ANALYZE
 
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
 
Techday2010 Postgresql9
Techday2010 Postgresql9Techday2010 Postgresql9
Techday2010 Postgresql9
 
Lazy beats Smart and Fast
Lazy beats Smart and FastLazy beats Smart and Fast
Lazy beats Smart and Fast
 
Plmce 14 be a_hero_16x9_final
Plmce 14 be a_hero_16x9_finalPlmce 14 be a_hero_16x9_final
Plmce 14 be a_hero_16x9_final
 
Performance improvements in PostgreSQL 9.5 and beyond
Performance improvements in PostgreSQL 9.5 and beyondPerformance improvements in PostgreSQL 9.5 and beyond
Performance improvements in PostgreSQL 9.5 and beyond
 
DataBase Management System Lab File
DataBase Management System Lab FileDataBase Management System Lab File
DataBase Management System Lab File
 
Oracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New FeaturesOracle Database 12.1.0.2 New Features
Oracle Database 12.1.0.2 New Features
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
 
PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6PostgreSQL performance improvements in 9.5 and 9.6
PostgreSQL performance improvements in 9.5 and 9.6
 
[Www.pkbulk.blogspot.com]dbms13
[Www.pkbulk.blogspot.com]dbms13[Www.pkbulk.blogspot.com]dbms13
[Www.pkbulk.blogspot.com]dbms13
 
Introduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]sIntroduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]s
 
MySQL Optimizer Cost Model
MySQL Optimizer Cost ModelMySQL Optimizer Cost Model
MySQL Optimizer Cost Model
 
DBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) pptDBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) ppt
 

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

SQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - AdvancedSQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - AdvancedTony Rogerson
 
Myth busters - performance tuning 103 2008
Myth busters - performance tuning 103 2008Myth busters - performance tuning 103 2008
Myth busters - performance tuning 103 2008paulguerin
 
10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQL10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQLSatoshi Nagayasu
 
Data Never Lies Presentation for beginners in data field.pptx
Data Never Lies Presentation for beginners in data field.pptxData Never Lies Presentation for beginners in data field.pptx
Data Never Lies Presentation for beginners in data field.pptxTusharAgarwal49094
 
Aioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_featuresAioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_featuresAiougVizagChapter
 
In memory databases presentation
In memory databases presentationIn memory databases presentation
In memory databases presentationMichael Keane
 
Hive and HiveQL - Module6
Hive and HiveQL - Module6Hive and HiveQL - Module6
Hive and HiveQL - Module6Rohit Agrawal
 
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptdatabase-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptIftikhar70
 
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptdatabase-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptsubbu998029
 
What's new in MariaDB TX 3.0
What's new in MariaDB TX 3.0What's new in MariaDB TX 3.0
What's new in MariaDB TX 3.0MariaDB plc
 
Database Performance
Database PerformanceDatabase Performance
Database PerformanceBoris Hristov
 
Работа с индексами - лучшие практики для MySQL 5.6, Петр Зайцев (Percona)
Работа с индексами - лучшие практики для MySQL 5.6, Петр Зайцев (Percona)Работа с индексами - лучшие практики для MySQL 5.6, Петр Зайцев (Percona)
Работа с индексами - лучшие практики для MySQL 5.6, Петр Зайцев (Percona)Ontico
 

Similaire à Юра Гуляев. Oracle tables (20)

1650607.ppt
1650607.ppt1650607.ppt
1650607.ppt
 
SQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - AdvancedSQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - Advanced
 
Myth busters - performance tuning 103 2008
Myth busters - performance tuning 103 2008Myth busters - performance tuning 103 2008
Myth busters - performance tuning 103 2008
 
10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQL10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQL
 
Tunning overview
Tunning overviewTunning overview
Tunning overview
 
Data Never Lies Presentation for beginners in data field.pptx
Data Never Lies Presentation for beginners in data field.pptxData Never Lies Presentation for beginners in data field.pptx
Data Never Lies Presentation for beginners in data field.pptx
 
Aioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_featuresAioug vizag oracle12c_new_features
Aioug vizag oracle12c_new_features
 
In memory databases presentation
In memory databases presentationIn memory databases presentation
In memory databases presentation
 
Hive and HiveQL - Module6
Hive and HiveQL - Module6Hive and HiveQL - Module6
Hive and HiveQL - Module6
 
Database Sizing
Database SizingDatabase Sizing
Database Sizing
 
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptdatabase-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
 
database-stucture-and-space-managment.ppt
database-stucture-and-space-managment.pptdatabase-stucture-and-space-managment.ppt
database-stucture-and-space-managment.ppt
 
DBMS Chapter-3.ppsx
DBMS Chapter-3.ppsxDBMS Chapter-3.ppsx
DBMS Chapter-3.ppsx
 
Indexing
IndexingIndexing
Indexing
 
Deep Dive on Amazon Redshift
Deep Dive on Amazon RedshiftDeep Dive on Amazon Redshift
Deep Dive on Amazon Redshift
 
What's new in MariaDB TX 3.0
What's new in MariaDB TX 3.0What's new in MariaDB TX 3.0
What's new in MariaDB TX 3.0
 
Deep Dive on Amazon Redshift
Deep Dive on Amazon RedshiftDeep Dive on Amazon Redshift
Deep Dive on Amazon Redshift
 
Deep Dive on Amazon Redshift
Deep Dive on Amazon RedshiftDeep Dive on Amazon Redshift
Deep Dive on Amazon Redshift
 
Database Performance
Database PerformanceDatabase Performance
Database Performance
 
Работа с индексами - лучшие практики для MySQL 5.6, Петр Зайцев (Percona)
Работа с индексами - лучшие практики для MySQL 5.6, Петр Зайцев (Percona)Работа с индексами - лучшие практики для MySQL 5.6, Петр Зайцев (Percona)
Работа с индексами - лучшие практики для MySQL 5.6, Петр Зайцев (Percona)
 

Dernier

Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Dernier (20)

Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Юра Гуляев. 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