SlideShare una empresa de Scribd logo
1 de 14
Descargar para leer sin conexión
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.

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Similar 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
 

Similar 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

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
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
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
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
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
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
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
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
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 

Último (20)

The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
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
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
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 ...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
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...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
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 🔝✔️✔️
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 

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.