SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
In-Memory Computation
with Oracle PL/SQL
Use a Radix Tree structure
to determine International Calling Codes.
● Statement of a problem
● Long Distance Codes in a few words
● Reasons to move from SQL to PL/SQL in computations
● Radix Tree: Definition, implementation and results
Statement of a problem
What does a service provider, when processes requests
from subscribers for outgoing calls ?
Every time when the caller dials the phone number...
...something like +35621316599, the operator is
required to determine the direction of the call, to
connect the calling and called party.
Information about the direction of the call is International Calling Code
(АКА Long Distance Code, AKA Dial Prefix).
Despite the presence of technical recommendations, such as
ITU-T Recommendations E.164 and E.123, reference used by
operators contain Long Distance Codes in an unstructured way,
without a separating code fields by Country and Region code,
Trunk code, etc.
Long Distance Codes in a few words
Thus, for the Dial 79654012345 the direction of the
call will be a string from the reference table maximally
coinciding with the beginning of a Dial string, i.e.
796540.
This is one and only rule to find the Long Distance
Code within Dial string.
It should also be taken into account: we have several upstream service providers
for outgoing calls.
Try to search with SQL
Collect statistics about SQL request for the Dial prefix in production
environment:
● Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit
Production
● Database server with Intel(R) Xeon(R) CPU E5620 2.40GHz stepping
02, 32 GB RAM
● Number of the unique prefixes 19 278
● MAX length of the prefix 11 characters
Try to search with SQL
Grab 28 219 phone numbers from accounting data, pass it into the below query:
SELECT /*+ GATHER_PLAN_STATISTICS */ tpc_phone_prefix
FROM (
SELECT tpc_phone_prefix
FROM tplan_provider_cost
WHERE :P1 LIKE tpc_phone_prefix || '%'
ORDER BY LENGTHC(tpc_phone_prefix) DESC
) WHERE ROWNUM < 2
...then take a look at V$SQLAREA and access plan for the query
Try to search with SQL
INDEX FAST FULL SCAN with AVG_ELAPSED about ~0.08 sec. per execution
● EXECUTIONS: 28 219
● DISK_READS: 3 904
● BUFFER_GETS: 111 235 752
● AVG_CPU (per exec): 0.076 584
● AVG_ELAPSED (per exec): 0.076 704
What's wrong ?
We scan too wide range of the values with SQL LIKE condition,
whereas real statistics show the following:
The most used prefixes have a length in the range of 3-5 characters.
Definitely, we need another method to search the prefix...
Move from SQL to PL/SQL
Reasons to Move:
● OLTP behavior in the Calls processing, every request
processed individually;
● Context switching between SQL and PL/SQL has a value,
especially with a large number of short queries;
● There is no concurrent issues to access PGA memory after its
allocation to session, contrary to shared data buffers in SGA;
Radix Tree as a solution of the issue
Citation from Wikipedia:
In computer science, a radix tree (also radix trie or
compact prefix tree) is a data structure that represents
a space-optimized trie in which each node that is the
only child is merged with its parent.
It's looks like similarly as a set of prefixes
from page 3, isn't it?
We will be guided by the following rules:
● Searching for a prefix terminates when leaf
node was reached;
● Searching for a prefix terminates within a
node that has no transition for the next
symbol of a dialed phone number.
Radix Tree as a solution of the issue
Now we need to define a structure to organize the data as a trie
in a memory of PL/SQL.
Radix Tree as a solution of the issue
Radix Tree as a solution of the issue
Radix Tree MethodsBulk load the whole set of Radix Tree data.
PROCEDURE BulkLoad(
tData IN OUT NOCOPY RXT_WBM.RXT_TAB
, sClearStored IN SIGNTYPE
DEFAULT STD.STATE_OK
);
Scan and Validate the Tree for absence of a loose path, i.e. path without root Node in the its start.
FUNCTION ChkTree RETURN BINARY_INTEGER;
Returns the RXT_PREFIX_REC structure for the Key maximally coinciding with the beginning of the
vKey parameter. Also returns the Key itself in a second IN OUT parameter.
FUNCTION GetPrefix(
vKey IN OUT NOCOPY RXT_WBM.RXT_KEY_REG
, recPrefix IN OUT NOCOPY RXT_WBM.RXT_PREFIX_REC
, PBitMap IN RXT_WBM.RXT_BIT_MAP_REG
) RETURN RXT_WBM.RXT_KEY;
TYPE RXT_PREFIX_REC IS RECORD (
ID POSITIVE
, Prefix RXT_KEY_PREFIX
, AllBlocked SIGNTYPE
);
Returns count of members in a Tree nested table container.
FUNCTION TreeSize RETURN BINARY_INTEGER;
Accept the Node ID, find it in a Tree and restore value of associated Key by traversal to the root Node.
FUNCTION ID_TO_KEY(
iID IN POSITIVEN
) RETURN RXT.RXT_KEY;
Radix Tree performance testing
Bulk load whole Tree via BulkLoad() ~0.08 sec.
Validate Tree via ChkTree () ~2.8 sec.
Set of single executions of GetPrefix() in anonymous PL/SQL block
Execution time varies from value of vKey parameter.
Elapsed time in range ~0.000 037 - 0.000 043 sec.
Batch execution of GetPrefix()
Batch testing with 33 953 unique Phone Numbers successfully
dialed in a Production environment.
Average time per execution ~0.000 011 sec.

Mais conteúdo relacionado

Mais procurados

Operations on linked list
Operations on linked listOperations on linked list
Operations on linked listSumathi Kv
 
Lecture 6: linked list
Lecture 6:  linked listLecture 6:  linked list
Lecture 6: linked listVivek Bhargav
 
Circular linked list
Circular linked listCircular linked list
Circular linked listmaamir farooq
 
Link list presentation slide(Daffodil international university)
Link list presentation slide(Daffodil international university)Link list presentation slide(Daffodil international university)
Link list presentation slide(Daffodil international university)shah alom
 
Linked lists in Data Structure
Linked lists in Data StructureLinked lists in Data Structure
Linked lists in Data StructureMuhazzab Chouhadry
 
Data structure doubly linked list programs
Data structure doubly linked list programsData structure doubly linked list programs
Data structure doubly linked list programsiCreateWorld
 
Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & DeletionAfaq Mansoor Khan
 
linked list using c
linked list using clinked list using c
linked list using cVenkat Reddy
 
Sedna XML Database: Query Parser & Optimizing Rewriter
Sedna XML Database: Query Parser & Optimizing RewriterSedna XML Database: Query Parser & Optimizing Rewriter
Sedna XML Database: Query Parser & Optimizing RewriterIvan Shcheklein
 
Sedna XML Database: Executor Internals
Sedna XML Database: Executor InternalsSedna XML Database: Executor Internals
Sedna XML Database: Executor InternalsIvan Shcheklein
 
Sedna XML Database System: Internal Representation
Sedna XML Database System: Internal RepresentationSedna XML Database System: Internal Representation
Sedna XML Database System: Internal RepresentationIvan Shcheklein
 

Mais procurados (20)

Operations on linked list
Operations on linked listOperations on linked list
Operations on linked list
 
Lecture 6: linked list
Lecture 6:  linked listLecture 6:  linked list
Lecture 6: linked list
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
Linked list
Linked listLinked list
Linked list
 
CSE240 Doubly Linked Lists
CSE240 Doubly Linked ListsCSE240 Doubly Linked Lists
CSE240 Doubly Linked Lists
 
LINKED LISTS
LINKED LISTSLINKED LISTS
LINKED LISTS
 
Link list presentation slide(Daffodil international university)
Link list presentation slide(Daffodil international university)Link list presentation slide(Daffodil international university)
Link list presentation slide(Daffodil international university)
 
Linked list
Linked listLinked list
Linked list
 
Linked lists in Data Structure
Linked lists in Data StructureLinked lists in Data Structure
Linked lists in Data Structure
 
Data structure doubly linked list programs
Data structure doubly linked list programsData structure doubly linked list programs
Data structure doubly linked list programs
 
Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & Deletion
 
linked list using c
linked list using clinked list using c
linked list using c
 
linked list
linked list linked list
linked list
 
Linked list
Linked listLinked list
Linked list
 
Programmable Logic Array
Programmable Logic Array Programmable Logic Array
Programmable Logic Array
 
Linked list
Linked list Linked list
Linked list
 
Sedna XML Database: Query Parser & Optimizing Rewriter
Sedna XML Database: Query Parser & Optimizing RewriterSedna XML Database: Query Parser & Optimizing Rewriter
Sedna XML Database: Query Parser & Optimizing Rewriter
 
Data Structure (Double Linked List)
Data Structure (Double Linked List)Data Structure (Double Linked List)
Data Structure (Double Linked List)
 
Sedna XML Database: Executor Internals
Sedna XML Database: Executor InternalsSedna XML Database: Executor Internals
Sedna XML Database: Executor Internals
 
Sedna XML Database System: Internal Representation
Sedna XML Database System: Internal RepresentationSedna XML Database System: Internal Representation
Sedna XML Database System: Internal Representation
 

Semelhante a PL/SQL and radix tree structure

How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012Connor McDonald
 
11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01Karam Abuataya
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11gfcamachob
 
Mysqlppt
MysqlpptMysqlppt
MysqlpptReka
 
Distributed Queries in IDS: New features.
Distributed Queries in IDS: New features.Distributed Queries in IDS: New features.
Distributed Queries in IDS: New features.Keshav Murthy
 
Spark Structured APIs
Spark Structured APIsSpark Structured APIs
Spark Structured APIsKnoldus Inc.
 
User Defined Partitioning on PlazmaDB
User Defined Partitioning on PlazmaDBUser Defined Partitioning on PlazmaDB
User Defined Partitioning on PlazmaDBKai Sasaki
 
Introduction to Parallel Execution
Introduction to Parallel ExecutionIntroduction to Parallel Execution
Introduction to Parallel ExecutionDoug Burns
 
HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)akirahiguchi
 
Five more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQLFive more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQLConnor McDonald
 
When Apache Spark Meets TiDB with Xiaoyu Ma
When Apache Spark Meets TiDB with Xiaoyu MaWhen Apache Spark Meets TiDB with Xiaoyu Ma
When Apache Spark Meets TiDB with Xiaoyu MaDatabricks
 
Using SQL-MapReduce for Advanced Analytics
Using SQL-MapReduce for Advanced AnalyticsUsing SQL-MapReduce for Advanced Analytics
Using SQL-MapReduce for Advanced AnalyticsTeradata Aster
 
Components of computer systems often have dependencies--other co.pdf
Components of computer systems often have dependencies--other co.pdfComponents of computer systems often have dependencies--other co.pdf
Components of computer systems often have dependencies--other co.pdfalamodeindia1
 
2007 Tidc India Profiling
2007 Tidc India Profiling2007 Tidc India Profiling
2007 Tidc India Profilingdanrinkes
 
Language Integrated Query By Nyros Developer
Language Integrated Query By Nyros DeveloperLanguage Integrated Query By Nyros Developer
Language Integrated Query By Nyros DeveloperNyros Technologies
 

Semelhante a PL/SQL and radix tree structure (20)

How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012How to tune a query - ODTUG 2012
How to tune a query - ODTUG 2012
 
11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01
 
11 Things About11g
11 Things About11g11 Things About11g
11 Things About11g
 
PHP tips by a MYSQL DBA
PHP tips by a MYSQL DBAPHP tips by a MYSQL DBA
PHP tips by a MYSQL DBA
 
SQL Windowing
SQL WindowingSQL Windowing
SQL Windowing
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Distributed Queries in IDS: New features.
Distributed Queries in IDS: New features.Distributed Queries in IDS: New features.
Distributed Queries in IDS: New features.
 
Spark Structured APIs
Spark Structured APIsSpark Structured APIs
Spark Structured APIs
 
06.pptx
06.pptx06.pptx
06.pptx
 
System Software
System SoftwareSystem Software
System Software
 
Les03 Single Row Function
Les03 Single Row FunctionLes03 Single Row Function
Les03 Single Row Function
 
User Defined Partitioning on PlazmaDB
User Defined Partitioning on PlazmaDBUser Defined Partitioning on PlazmaDB
User Defined Partitioning on PlazmaDB
 
Introduction to Parallel Execution
Introduction to Parallel ExecutionIntroduction to Parallel Execution
Introduction to Parallel Execution
 
HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)HandlerSocket plugin for MySQL (English)
HandlerSocket plugin for MySQL (English)
 
Five more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQLFive more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQL
 
When Apache Spark Meets TiDB with Xiaoyu Ma
When Apache Spark Meets TiDB with Xiaoyu MaWhen Apache Spark Meets TiDB with Xiaoyu Ma
When Apache Spark Meets TiDB with Xiaoyu Ma
 
Using SQL-MapReduce for Advanced Analytics
Using SQL-MapReduce for Advanced AnalyticsUsing SQL-MapReduce for Advanced Analytics
Using SQL-MapReduce for Advanced Analytics
 
Components of computer systems often have dependencies--other co.pdf
Components of computer systems often have dependencies--other co.pdfComponents of computer systems often have dependencies--other co.pdf
Components of computer systems often have dependencies--other co.pdf
 
2007 Tidc India Profiling
2007 Tidc India Profiling2007 Tidc India Profiling
2007 Tidc India Profiling
 
Language Integrated Query By Nyros Developer
Language Integrated Query By Nyros DeveloperLanguage Integrated Query By Nyros Developer
Language Integrated Query By Nyros Developer
 

Último

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 

Último (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

PL/SQL and radix tree structure

  • 1. In-Memory Computation with Oracle PL/SQL Use a Radix Tree structure to determine International Calling Codes. ● Statement of a problem ● Long Distance Codes in a few words ● Reasons to move from SQL to PL/SQL in computations ● Radix Tree: Definition, implementation and results
  • 2. Statement of a problem What does a service provider, when processes requests from subscribers for outgoing calls ? Every time when the caller dials the phone number... ...something like +35621316599, the operator is required to determine the direction of the call, to connect the calling and called party. Information about the direction of the call is International Calling Code (АКА Long Distance Code, AKA Dial Prefix).
  • 3. Despite the presence of technical recommendations, such as ITU-T Recommendations E.164 and E.123, reference used by operators contain Long Distance Codes in an unstructured way, without a separating code fields by Country and Region code, Trunk code, etc. Long Distance Codes in a few words Thus, for the Dial 79654012345 the direction of the call will be a string from the reference table maximally coinciding with the beginning of a Dial string, i.e. 796540. This is one and only rule to find the Long Distance Code within Dial string. It should also be taken into account: we have several upstream service providers for outgoing calls.
  • 4. Try to search with SQL Collect statistics about SQL request for the Dial prefix in production environment: ● Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production ● Database server with Intel(R) Xeon(R) CPU E5620 2.40GHz stepping 02, 32 GB RAM ● Number of the unique prefixes 19 278 ● MAX length of the prefix 11 characters
  • 5. Try to search with SQL Grab 28 219 phone numbers from accounting data, pass it into the below query: SELECT /*+ GATHER_PLAN_STATISTICS */ tpc_phone_prefix FROM ( SELECT tpc_phone_prefix FROM tplan_provider_cost WHERE :P1 LIKE tpc_phone_prefix || '%' ORDER BY LENGTHC(tpc_phone_prefix) DESC ) WHERE ROWNUM < 2 ...then take a look at V$SQLAREA and access plan for the query
  • 6. Try to search with SQL INDEX FAST FULL SCAN with AVG_ELAPSED about ~0.08 sec. per execution ● EXECUTIONS: 28 219 ● DISK_READS: 3 904 ● BUFFER_GETS: 111 235 752 ● AVG_CPU (per exec): 0.076 584 ● AVG_ELAPSED (per exec): 0.076 704
  • 7. What's wrong ? We scan too wide range of the values with SQL LIKE condition, whereas real statistics show the following: The most used prefixes have a length in the range of 3-5 characters. Definitely, we need another method to search the prefix...
  • 8. Move from SQL to PL/SQL Reasons to Move: ● OLTP behavior in the Calls processing, every request processed individually; ● Context switching between SQL and PL/SQL has a value, especially with a large number of short queries; ● There is no concurrent issues to access PGA memory after its allocation to session, contrary to shared data buffers in SGA;
  • 9. Radix Tree as a solution of the issue Citation from Wikipedia: In computer science, a radix tree (also radix trie or compact prefix tree) is a data structure that represents a space-optimized trie in which each node that is the only child is merged with its parent. It's looks like similarly as a set of prefixes from page 3, isn't it?
  • 10. We will be guided by the following rules: ● Searching for a prefix terminates when leaf node was reached; ● Searching for a prefix terminates within a node that has no transition for the next symbol of a dialed phone number. Radix Tree as a solution of the issue Now we need to define a structure to organize the data as a trie in a memory of PL/SQL.
  • 11. Radix Tree as a solution of the issue
  • 12. Radix Tree as a solution of the issue
  • 13. Radix Tree MethodsBulk load the whole set of Radix Tree data. PROCEDURE BulkLoad( tData IN OUT NOCOPY RXT_WBM.RXT_TAB , sClearStored IN SIGNTYPE DEFAULT STD.STATE_OK ); Scan and Validate the Tree for absence of a loose path, i.e. path without root Node in the its start. FUNCTION ChkTree RETURN BINARY_INTEGER; Returns the RXT_PREFIX_REC structure for the Key maximally coinciding with the beginning of the vKey parameter. Also returns the Key itself in a second IN OUT parameter. FUNCTION GetPrefix( vKey IN OUT NOCOPY RXT_WBM.RXT_KEY_REG , recPrefix IN OUT NOCOPY RXT_WBM.RXT_PREFIX_REC , PBitMap IN RXT_WBM.RXT_BIT_MAP_REG ) RETURN RXT_WBM.RXT_KEY; TYPE RXT_PREFIX_REC IS RECORD ( ID POSITIVE , Prefix RXT_KEY_PREFIX , AllBlocked SIGNTYPE ); Returns count of members in a Tree nested table container. FUNCTION TreeSize RETURN BINARY_INTEGER; Accept the Node ID, find it in a Tree and restore value of associated Key by traversal to the root Node. FUNCTION ID_TO_KEY( iID IN POSITIVEN ) RETURN RXT.RXT_KEY;
  • 14. Radix Tree performance testing Bulk load whole Tree via BulkLoad() ~0.08 sec. Validate Tree via ChkTree () ~2.8 sec. Set of single executions of GetPrefix() in anonymous PL/SQL block Execution time varies from value of vKey parameter. Elapsed time in range ~0.000 037 - 0.000 043 sec. Batch execution of GetPrefix() Batch testing with 33 953 unique Phone Numbers successfully dialed in a Production environment. Average time per execution ~0.000 011 sec.