SlideShare a Scribd company logo
1 of 31
Download to read offline
PostgreSQL: Advanced features
         in practice

          JÁN SUCHAL
           22.11.2011
          @RUBYSLAVA
Why PostgreSQL?

 The world’s most advanced open source database.
 Features!
   Transactional DDL

   Cost-based query optimizer + Graphical explain

   Partial indexes

   Function indexes

   K-nearest search

   Views

   Recursive Queries

   Window Functions
Transactional DDL

class CreatePostsMigration < ActiveRecord::Migration
  def change
    create_table :posts do |t|
      t.string :name, null: false
      t.text :body, null: false
      t.references :author, null: false
      t.timestamps null: false
    end

    add_index :posts, :title, unique: true
  end
end

 Where is the problem?
Transactional DDL

class CreatePostsMigration < ActiveRecord::Migration
  def change
    create_table :posts do |t|
      t.string :name, null: false
                             Column title does not exist!
      t.text :body, null: false is created, index is not. Oops!
                             Table
      t.references :author, null: false
                             Transactional DDL FTW!
      t.timestamps null: false
    end

    add_index :posts, :title, unique: true
  end
end

 Where is the problem?
Cost-based query optimizer

 What is the best plan to execute a given query?
 Cost = I/O + CPU operations needed
 Sequential vs. random seek
 Join order
 Join type (nested loop, hash join, merge join)
Graphical EXPLAIN

 pgAdmin (www.pgadmin.org)
Partial indexes

 Conditional indexes
 Problem: Async job/queue table, find failed jobs
   Create index on failed_at column

   99% of index is never used
Partial indexes

 Conditional indexes
 Problem: Async job/queue table, find failed jobs
   Create index on failed_at column

   99% of index is never used



 Solution:
CREATE INDEX idx_dj_only_failed ON delayed_jobs (failed_at)
  WHERE failed_at IS NOT NULL;
    smaller index
    faster updates
Function Indexes

 Problem: Suffix search
   SELECT … WHERE code LIKE ‘%123’
Function Indexes

 Problem: Suffix search
   SELECT … WHERE code LIKE ‘%123’

 “Solution”:
   Add reverse_code column, populate, add triggers for updates,
    create index on reverse_code column
   reverse queries WHERE reverse_code LIKE “321%”
Function Indexes

 Problem: Suffix search
   SELECT … WHERE code LIKE ‘%123’

 “Solution”:
   Add reverse_code column, populate, add triggers for updates,
    create index on reverse_code column,
   reverse queries WHERE reverse_code LIKE “321%”



 PostgreSQL solution:
  CREATE INDEX idx_reversed ON projects
  (reverse((code)::text) text_pattern_ops);
  SELECT … WHERE reverse(code) LIKE
  reverse(‘%123’)
K-nearest search

 Problem: Fuzzy string matching
   900K rows




 CREATE INDEX idx_trgm_name ON subjects USING gist (name
 gist_trgm_ops);

 SELECT name, name <-> 'Michl Brla' AS dist
   FROM subjects ORDER BY dist ASC LIMIT 10; (312ms)

 "Michal Barla“   ;   0.588235
 "Michal Bula“    ;   0.647059
 "Michal Broz“    ;   0.647059
 "Pavel Michl“    ;   0.647059
 "Michal Brna“    ;   0.647059
K-nearest search

 Problem: Fuzzy string matching
   900K rows



 Solution: Ngram/Trigram search
   johno = {" j"," jo",”hno”,”joh”,"no ",”ohn”}

 CREATE INDEX idx_trgm_name ON subjects USING gist (name
 gist_trgm_ops);

 SELECT name, name <-> 'Michl Brla' AS dist
   FROM subjects ORDER BY dist ASC LIMIT 10; (312ms)

 "Michal Barla“   ;   0.588235
 "Michal Bula“    ;   0.647059
 "Michal Broz“    ;   0.647059
 "Pavel Michl“    ;   0.647059
 "Michal Brna“    ;   0.647059
K-nearest search

 Problem: Fuzzy string matching
   900K rows



 Solution: Ngram/Trigram search
   johno = {" j"," jo",”hno”,”joh”,"no ",”ohn”}

 CREATE INDEX idx_trgm_name ON subjects USING gist (name
 gist_trgm_ops);

 SELECT name, name <-> 'Michl Brla' AS dist
   FROM subjects ORDER BY dist ASC LIMIT 10; (312ms)

 "Michal Barla“   ;   0.588235
 "Michal Bula“    ;   0.647059
 "Michal Broz“    ;   0.647059
 "Pavel Michl“    ;   0.647059
 "Michal Brna“    ;   0.647059
Views

 Constraints propagated down to views

CREATE VIEW edges AS
  SELECT subject_id AS source_id,
    connected_subject_id AS target_id FROM raw_connections
  UNION ALL
  SELECT connected_subject_id AS source_id,
    subject_id AS target_id FROM raw_connections;

 SELECT * FROM edges WHERE source_id = 123;
 SELECT * FROM edges WHERE source_id < 500 ORDER BY
  source_id LIMIT 10
  No materialization, 2x indexed select + 1x append/merge
Views

 Constraints propagated down to views

CREATE VIEW edges AS
  SELECT subject_id AS source_id,
    connected_subject_id AS target_id FROM raw_connections
  UNION ALL
  SELECT connected_subject_id AS source_id,
    subject_id AS target_id FROM raw_connections;

 SELECT * FROM edges WHERE source_id = 123;
 SELECT * FROM edges WHERE source_id < 500 ORDER BY
  source_id LIMIT 10
     No materialization, 2x indexed select + 1x append/merge
Recursive Queries

 Problem: Find paths between two nodes in graph

WITH RECURSIVE search_graph(source,target,distance,path) AS
(
  SELECT source_id, target_id, 1,
    ARRAY[source_id, target_id]
  FROM edges WHERE source_id = 552506
  UNION ALL
  SELECT sg.source, e.target_id, sg.distance + 1,
    path || ARRAY[e.target_id]
  FROM search_graph sg
    JOIN edges e ON sg.target = e.source_id
    WHERE NOT e.target_id = ANY(path) AND distance < 4
)
SELECT * FROM search_graph LIMIT 100
Recursive Queries

 Problem: Find paths between two nodes in graph

WITH RECURSIVE search_graph(source,target,distance,path) AS
(
  SELECT source_id, target_id, 1,
    ARRAY[source_id, target_id]
  FROM edges WHERE source_id = 552506
  UNION ALL
  SELECT sg.source, e.target_id, sg.distance + 1,
    path || ARRAY[e.target_id]
  FROM search_graph sg
    JOIN edges e ON sg.target = e.source_id
    WHERE NOT e.target_id = ANY(path) AND distance < 4
)
SELECT * FROM search_graph LIMIT 100
Recursive Queries

 Problem: Find paths between two nodes in graph

WITH RECURSIVE search_graph(source,target,distance,path) AS
(
  SELECT source_id, target_id, 1,
    ARRAY[source_id, target_id]
  FROM edges WHERE source_id = 552506
  UNION ALL
  SELECT sg.source, e.target_id, sg.distance + 1,
    path || ARRAY[e.target_id]
  FROM search_graph sg
    JOIN edges e ON sg.target = e.source_id
    WHERE NOT e.target_id = ANY(path) AND distance < 4
)
SELECT * FROM search_graph WHERE target = 530556 LIMIT 100;
Recursive Queries

 Problem: Find paths between two nodes in graph

WITH RECURSIVE search_graph(source,target,distance,path) AS
(
  SELECT source_id, target_id, 1,
    ARRAY[source_id, target_id]
  FROM edges WHERE source_id = 552506
  UNION ALL
  SELECT sg.source, e.target_id, sg.distance + 1,
    path || ARRAY[e.target_id]
  FROM search_graph sg
    JOIN edges e ON sg.target = e.source_id
    WHERE NOT e.target_id = ANY(path) AND distance < 4
)
SELECT * FROM search_graph WHERE target = 530556 LIMIT 100;
Recursive Queries

 Problem: Find paths between two nodes in graph

WITH RECURSIVE search_graph(source,target,distance,path) AS
(
  SELECT source_id, target_id, 1,
    ARRAY[source_id, target_id]
  FROM edges WHERE source_id = 552506
  UNION ALL
  SELECT sg.source, e.target_id, sg.distance + 1,
    path || ARRAY[e.target_id]
  FROM search_graph sg
    JOIN edges e ON sg.target = e.source_id
    WHERE NOT e.target_id = ANY(path) AND distance < 4
)
SELECT * FROM search_graph WHERE target = 530556 LIMIT 100;
Recursive queries
Recursive queries

 Graph with ~1M edges (61ms)
 source; target; distance; path
 530556; 552506; 2; {530556,185423,552506}
   JUDr. Robert Kaliňák -> FoodRest s.r.o. -> Ing. Ján
    Počiatek

 530556; 552506; 2; {530556,183291,552506}
   JUDr. Robert Kaliňák -> FoRest s.r.o. -> Ing. Ján
    Počiatek

 530556; 552506; 4;
 {530556,183291,552522,185423,552506}
    JUDr. Robert Kaliňák -> FoodRest s.r.o. -> Lena
     Sisková -> FoRest s.r.o. -> Ing. Ján Počiatek
Window functions

 “Aggregate functions without grouping”
   avg, count, sum, rank, row_number, ntile…

 Problem: Find closest nodes to a given node
  Order by sum of path scores
  Path score = 0.9^<distance> / log(1 + <number of paths>)

SELECT source, target FROM (
 SELECT source, target, path, distance,
  0.9 ^ distance / log(1 +
   COUNT(*) OVER (PARTITION BY distance,target)
  ) AS score
 FROM ( … ) AS paths
) as scored_paths
GROUP BY source, target ORDER BY SUM(score) DESC
Window functions

 “Aggregate functions without grouping”
   avg, count, sum, rank, row_number, ntile…

 Problem: Find closest nodes to a given node
   Order by sum of path scores
   Path score = 0.9^<distance> / log(1 + <number of paths>)


SELECT source, target FROM (
 SELECT source, target, path, distance,
  0.9 ^ distance / log(1 +
   COUNT(*) OVER (PARTITION BY distance,target)
  ) AS score
 FROM ( … ) AS paths
) as scored_paths
GROUP BY source, target ORDER BY SUM(score) DESC
Window functions

 “Aggregate functions without grouping”
   avg, count, sum, rank, row_number, ntile…

 Problem: Find closest nodes to a given node
   Order by sum of path scores
   Path score = 0.9^<distance> / log(1 + <number of paths>)


SELECT source, target FROM (
 SELECT source, target, path, distance,
  0.9 ^ distance / log(1 +
   COUNT(*) OVER (PARTITION BY distance, target)
  ) AS n
 FROM ( … ) AS paths
) as scored_paths
GROUP BY source, target ORDER BY SUM(score) DESC
Window functions

 “Aggregate functions without grouping”
   avg, count, sum, rank, row_number, ntile…

 Problem: Find closest nodes to a given node
   Order by sum of path scores
   Path score = 0.9^<distance> / log(1 + <number of paths>)


SELECT source, target FROM (
 SELECT source, target, path, distance,
  0.9 ^ distance / log(1 +
   COUNT(*) OVER (PARTITION BY distance, target)
  ) AS score
 FROM ( … ) AS paths
) as scored_paths
GROUP BY source, target ORDER BY SUM(score) DESC
Window functions

 “Aggregate functions without grouping”
   avg, count, sum, rank, row_number, ntile…

 Problem: Find closest nodes to a given node
   Order by sum of path scores
   Path score = 0.9^<distance> / log(1 + <number of paths>)


SELECT source, target FROM (
 SELECT source, target, path, distance,
  0.9 ^ distance / log(1 +
   COUNT(*) OVER (PARTITION BY distance, target)
  ) AS score
 FROM ( … ) AS paths
) AS scored_paths
GROUP BY source, target ORDER BY SUM(score) DESC
Window functions

 Example: Closest to Róbert Kaliňák
  "Bussines Park Bratislava a.s."
  "JARABINY a.s."
  "Ing. Robert Pintér"
  "Ing. Ján Počiatek"
  "Bratislava trade center a.s.“
  …
 1M edges, 41ms
Additional resources

 www.postgresql.org
   Read the docs, seriously

 www.explainextended.com
   SQL guru blog

 explain.depesz.com
   First aid for slow queries

 www.wikivs.com/wiki/MySQL_vs_PostgreSQL
   MySQL vs. PostgreSQL comparison
Real World Explain

 www.postgresql.org

More Related Content

What's hot

Postgres rules
Postgres rulesPostgres rules
Postgres rulesgisborne
 
Python tutorial
Python tutorialPython tutorial
Python tutorialRajiv Risi
 
The Ring programming language version 1.5.2 book - Part 44 of 181
The Ring programming language version 1.5.2 book - Part 44 of 181The Ring programming language version 1.5.2 book - Part 44 of 181
The Ring programming language version 1.5.2 book - Part 44 of 181Mahmoud Samir Fayed
 
Unsung Heroes of PHP
Unsung Heroes of PHPUnsung Heroes of PHP
Unsung Heroes of PHPjsmith92
 
Postgresql 9.3 overview
Postgresql 9.3 overviewPostgresql 9.3 overview
Postgresql 9.3 overviewAveic
 
Implementing a many-to-many Relationship with Slick
Implementing a many-to-many Relationship with SlickImplementing a many-to-many Relationship with Slick
Implementing a many-to-many Relationship with SlickHermann Hueck
 
Getting started with R when analysing GitHub commits
Getting started with R when analysing GitHub commitsGetting started with R when analysing GitHub commits
Getting started with R when analysing GitHub commitsBarbara Fusinska
 
Graph Database Query Languages
Graph Database Query LanguagesGraph Database Query Languages
Graph Database Query LanguagesJay Coskey
 
Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?Lucas Witold Adamus
 
The Ring programming language version 1.5.3 book - Part 30 of 184
The Ring programming language version 1.5.3 book - Part 30 of 184The Ring programming language version 1.5.3 book - Part 30 of 184
The Ring programming language version 1.5.3 book - Part 30 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 35 of 202
The Ring programming language version 1.8 book - Part 35 of 202The Ring programming language version 1.8 book - Part 35 of 202
The Ring programming language version 1.8 book - Part 35 of 202Mahmoud Samir Fayed
 
WorkingWithSlick2.1.0
WorkingWithSlick2.1.0WorkingWithSlick2.1.0
WorkingWithSlick2.1.0Knoldus Inc.
 
Programming Haskell Chapter8
Programming Haskell Chapter8Programming Haskell Chapter8
Programming Haskell Chapter8Kousuke Ruichi
 

What's hot (20)

Postgres rules
Postgres rulesPostgres rules
Postgres rules
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 
A tour of Python
A tour of PythonA tour of Python
A tour of Python
 
The Ring programming language version 1.5.2 book - Part 44 of 181
The Ring programming language version 1.5.2 book - Part 44 of 181The Ring programming language version 1.5.2 book - Part 44 of 181
The Ring programming language version 1.5.2 book - Part 44 of 181
 
Unsung Heroes of PHP
Unsung Heroes of PHPUnsung Heroes of PHP
Unsung Heroes of PHP
 
Postgresql 9.3 overview
Postgresql 9.3 overviewPostgresql 9.3 overview
Postgresql 9.3 overview
 
Implementing a many-to-many Relationship with Slick
Implementing a many-to-many Relationship with SlickImplementing a many-to-many Relationship with Slick
Implementing a many-to-many Relationship with Slick
 
Green dao
Green daoGreen dao
Green dao
 
Xm lparsers
Xm lparsersXm lparsers
Xm lparsers
 
Ggplot2 v3
Ggplot2 v3Ggplot2 v3
Ggplot2 v3
 
Getting started with R when analysing GitHub commits
Getting started with R when analysing GitHub commitsGetting started with R when analysing GitHub commits
Getting started with R when analysing GitHub commits
 
Graph Database Query Languages
Graph Database Query LanguagesGraph Database Query Languages
Graph Database Query Languages
 
Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?
 
Scala best practices
Scala best practicesScala best practices
Scala best practices
 
The Ring programming language version 1.5.3 book - Part 30 of 184
The Ring programming language version 1.5.3 book - Part 30 of 184The Ring programming language version 1.5.3 book - Part 30 of 184
The Ring programming language version 1.5.3 book - Part 30 of 184
 
Pytables
PytablesPytables
Pytables
 
JDK 8
JDK 8JDK 8
JDK 8
 
The Ring programming language version 1.8 book - Part 35 of 202
The Ring programming language version 1.8 book - Part 35 of 202The Ring programming language version 1.8 book - Part 35 of 202
The Ring programming language version 1.8 book - Part 35 of 202
 
WorkingWithSlick2.1.0
WorkingWithSlick2.1.0WorkingWithSlick2.1.0
WorkingWithSlick2.1.0
 
Programming Haskell Chapter8
Programming Haskell Chapter8Programming Haskell Chapter8
Programming Haskell Chapter8
 

Viewers also liked

Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Alexey Lesovsky
 
PostgreSQL Advanced Queries
PostgreSQL Advanced QueriesPostgreSQL Advanced Queries
PostgreSQL Advanced QueriesNur Hidayat
 
Troubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming ReplicationTroubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming ReplicationAlexey Lesovsky
 
Сравнение форматов и библиотек сериализации / Антон Рыжов (Qrator Labs)
Сравнение форматов и библиотек сериализации / Антон Рыжов (Qrator Labs)Сравнение форматов и библиотек сериализации / Антон Рыжов (Qrator Labs)
Сравнение форматов и библиотек сериализации / Антон Рыжов (Qrator Labs)Ontico
 
Streaming replication in practice
Streaming replication in practiceStreaming replication in practice
Streaming replication in practiceAlexey Lesovsky
 
Mission: Launch a Digital Workplace
Mission: Launch a Digital Workplace Mission: Launch a Digital Workplace
Mission: Launch a Digital Workplace BMC Software
 
Et si la RH partagée devenait une nouvelle spécialité bretonne ?
Et si la RH partagée devenait une nouvelle spécialité bretonne ?Et si la RH partagée devenait une nouvelle spécialité bretonne ?
Et si la RH partagée devenait une nouvelle spécialité bretonne ?EMERAUDE RH
 
PrescriptionPillsToHeroine_hw Copy
PrescriptionPillsToHeroine_hw CopyPrescriptionPillsToHeroine_hw Copy
PrescriptionPillsToHeroine_hw CopyAmber Hollingsworth
 
Goed jaar voor firma Kevin Pauwels
Goed jaar voor firma Kevin PauwelsGoed jaar voor firma Kevin Pauwels
Goed jaar voor firma Kevin PauwelsThierry Debels
 
TRUSTLESS.AI and Trustless Computing Consortium
TRUSTLESS.AI and Trustless Computing ConsortiumTRUSTLESS.AI and Trustless Computing Consortium
TRUSTLESS.AI and Trustless Computing ConsortiumTRUSTLESS.AI
 
Los Desafíos de la educación a distancia
Los Desafíos de la educación a distanciaLos Desafíos de la educación a distancia
Los Desafíos de la educación a distanciaClaudio Rama
 
The adoption and impact of OEP and OER in the Global South: Theoretical, conc...
The adoption and impact of OEP and OER in the Global South: Theoretical, conc...The adoption and impact of OEP and OER in the Global South: Theoretical, conc...
The adoption and impact of OEP and OER in the Global South: Theoretical, conc...ROER4D
 
Game Studio Leadership: You Can Do It
Game Studio Leadership: You Can Do ItGame Studio Leadership: You Can Do It
Game Studio Leadership: You Can Do ItJesse Schell
 
MOOC Aspects juridiques de la création d'entreprises innovantes - attestation
MOOC Aspects juridiques de la création d'entreprises innovantes -  attestationMOOC Aspects juridiques de la création d'entreprises innovantes -  attestation
MOOC Aspects juridiques de la création d'entreprises innovantes - attestationAudrey Jacob
 
Choosing Open (#OEGlobal) - Openness and praxis: Using OEP in HE
Choosing Open (#OEGlobal) - Openness and praxis: Using OEP in HEChoosing Open (#OEGlobal) - Openness and praxis: Using OEP in HE
Choosing Open (#OEGlobal) - Openness and praxis: Using OEP in HECatherine Cronin
 
Marketing Week Live 2017
Marketing Week Live 2017Marketing Week Live 2017
Marketing Week Live 2017Jeremy Waite
 
コードクローン研究 ふりかえり ~ストロング・スタイルで行こう~
コードクローン研究 ふりかえり ~ストロング・スタイルで行こう~コードクローン研究 ふりかえり ~ストロング・スタイルで行こう~
コードクローン研究 ふりかえり ~ストロング・スタイルで行こう~Kamiya Toshihiro
 
はじめての CircleCI
はじめての CircleCIはじめての CircleCI
はじめての CircleCIYosuke Mizutani
 

Viewers also liked (20)

Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
PostgreSQL Advanced Queries
PostgreSQL Advanced QueriesPostgreSQL Advanced Queries
PostgreSQL Advanced Queries
 
Troubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming ReplicationTroubleshooting PostgreSQL Streaming Replication
Troubleshooting PostgreSQL Streaming Replication
 
Сравнение форматов и библиотек сериализации / Антон Рыжов (Qrator Labs)
Сравнение форматов и библиотек сериализации / Антон Рыжов (Qrator Labs)Сравнение форматов и библиотек сериализации / Антон Рыжов (Qrator Labs)
Сравнение форматов и библиотек сериализации / Антон Рыжов (Qrator Labs)
 
Streaming replication in practice
Streaming replication in practiceStreaming replication in practice
Streaming replication in practice
 
Freedom! Employee Empowerment the $2000 Way
Freedom! Employee Empowerment the $2000 WayFreedom! Employee Empowerment the $2000 Way
Freedom! Employee Empowerment the $2000 Way
 
Mission: Launch a Digital Workplace
Mission: Launch a Digital Workplace Mission: Launch a Digital Workplace
Mission: Launch a Digital Workplace
 
Et si la RH partagée devenait une nouvelle spécialité bretonne ?
Et si la RH partagée devenait une nouvelle spécialité bretonne ?Et si la RH partagée devenait une nouvelle spécialité bretonne ?
Et si la RH partagée devenait une nouvelle spécialité bretonne ?
 
PrescriptionPillsToHeroine_hw Copy
PrescriptionPillsToHeroine_hw CopyPrescriptionPillsToHeroine_hw Copy
PrescriptionPillsToHeroine_hw Copy
 
Goed jaar voor firma Kevin Pauwels
Goed jaar voor firma Kevin PauwelsGoed jaar voor firma Kevin Pauwels
Goed jaar voor firma Kevin Pauwels
 
TRUSTLESS.AI and Trustless Computing Consortium
TRUSTLESS.AI and Trustless Computing ConsortiumTRUSTLESS.AI and Trustless Computing Consortium
TRUSTLESS.AI and Trustless Computing Consortium
 
Mesa job _fair_flyer
Mesa job _fair_flyerMesa job _fair_flyer
Mesa job _fair_flyer
 
Los Desafíos de la educación a distancia
Los Desafíos de la educación a distanciaLos Desafíos de la educación a distancia
Los Desafíos de la educación a distancia
 
The adoption and impact of OEP and OER in the Global South: Theoretical, conc...
The adoption and impact of OEP and OER in the Global South: Theoretical, conc...The adoption and impact of OEP and OER in the Global South: Theoretical, conc...
The adoption and impact of OEP and OER in the Global South: Theoretical, conc...
 
Game Studio Leadership: You Can Do It
Game Studio Leadership: You Can Do ItGame Studio Leadership: You Can Do It
Game Studio Leadership: You Can Do It
 
MOOC Aspects juridiques de la création d'entreprises innovantes - attestation
MOOC Aspects juridiques de la création d'entreprises innovantes -  attestationMOOC Aspects juridiques de la création d'entreprises innovantes -  attestation
MOOC Aspects juridiques de la création d'entreprises innovantes - attestation
 
Choosing Open (#OEGlobal) - Openness and praxis: Using OEP in HE
Choosing Open (#OEGlobal) - Openness and praxis: Using OEP in HEChoosing Open (#OEGlobal) - Openness and praxis: Using OEP in HE
Choosing Open (#OEGlobal) - Openness and praxis: Using OEP in HE
 
Marketing Week Live 2017
Marketing Week Live 2017Marketing Week Live 2017
Marketing Week Live 2017
 
コードクローン研究 ふりかえり ~ストロング・スタイルで行こう~
コードクローン研究 ふりかえり ~ストロング・スタイルで行こう~コードクローン研究 ふりかえり ~ストロング・スタイルで行こう~
コードクローン研究 ふりかえり ~ストロング・スタイルで行こう~
 
はじめての CircleCI
はじめての CircleCIはじめての CircleCI
はじめての CircleCI
 

Similar to PostgreSQL: Advanced features in practice

GreenDao Introduction
GreenDao IntroductionGreenDao Introduction
GreenDao IntroductionBooch Lin
 
Importing Data into Neo4j quickly and easily - StackOverflow
Importing Data into Neo4j quickly and easily - StackOverflowImporting Data into Neo4j quickly and easily - StackOverflow
Importing Data into Neo4j quickly and easily - StackOverflowNeo4j
 
PerlApp2Postgresql (2)
PerlApp2Postgresql (2)PerlApp2Postgresql (2)
PerlApp2Postgresql (2)Jerome Eteve
 
GraphConnect Europe 2016 - Importing Data - Mark Needham, Michael Hunger
GraphConnect Europe 2016 - Importing Data - Mark Needham, Michael HungerGraphConnect Europe 2016 - Importing Data - Mark Needham, Michael Hunger
GraphConnect Europe 2016 - Importing Data - Mark Needham, Michael HungerNeo4j
 
Joins and Other MongoDB 3.2 Aggregation Enhancements
Joins and Other MongoDB 3.2 Aggregation EnhancementsJoins and Other MongoDB 3.2 Aggregation Enhancements
Joins and Other MongoDB 3.2 Aggregation EnhancementsAndrew Morgan
 
Graph Connect: Importing data quickly and easily
Graph Connect: Importing data quickly and easilyGraph Connect: Importing data quickly and easily
Graph Connect: Importing data quickly and easilyMark Needham
 
MongoDB Aggregation
MongoDB Aggregation MongoDB Aggregation
MongoDB Aggregation Amit Ghosh
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation FrameworkCaserta
 
Mapping Graph Queries to PostgreSQL
Mapping Graph Queries to PostgreSQLMapping Graph Queries to PostgreSQL
Mapping Graph Queries to PostgreSQLGábor Szárnyas
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeWim Godden
 
Cassandra Data Modeling
Cassandra Data ModelingCassandra Data Modeling
Cassandra Data ModelingBen Knear
 
Tactical data engineering
Tactical data engineeringTactical data engineering
Tactical data engineeringJulian Hyde
 
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial IndexesBack to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial IndexesMongoDB
 
Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...Andreas Dewes
 
PPT on Data Science Using Python
PPT on Data Science Using PythonPPT on Data Science Using Python
PPT on Data Science Using PythonNishantKumar1179
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212Mahmoud Samir Fayed
 

Similar to PostgreSQL: Advanced features in practice (20)

GreenDao Introduction
GreenDao IntroductionGreenDao Introduction
GreenDao Introduction
 
Importing Data into Neo4j quickly and easily - StackOverflow
Importing Data into Neo4j quickly and easily - StackOverflowImporting Data into Neo4j quickly and easily - StackOverflow
Importing Data into Neo4j quickly and easily - StackOverflow
 
PerlApp2Postgresql (2)
PerlApp2Postgresql (2)PerlApp2Postgresql (2)
PerlApp2Postgresql (2)
 
GraphConnect Europe 2016 - Importing Data - Mark Needham, Michael Hunger
GraphConnect Europe 2016 - Importing Data - Mark Needham, Michael HungerGraphConnect Europe 2016 - Importing Data - Mark Needham, Michael Hunger
GraphConnect Europe 2016 - Importing Data - Mark Needham, Michael Hunger
 
Joins and Other MongoDB 3.2 Aggregation Enhancements
Joins and Other MongoDB 3.2 Aggregation EnhancementsJoins and Other MongoDB 3.2 Aggregation Enhancements
Joins and Other MongoDB 3.2 Aggregation Enhancements
 
Graph Connect: Importing data quickly and easily
Graph Connect: Importing data quickly and easilyGraph Connect: Importing data quickly and easily
Graph Connect: Importing data quickly and easily
 
MongoDB
MongoDB MongoDB
MongoDB
 
MySQL Indexes
MySQL IndexesMySQL Indexes
MySQL Indexes
 
MongoDB Aggregation
MongoDB Aggregation MongoDB Aggregation
MongoDB Aggregation
 
MongoDB Aggregation Framework
MongoDB Aggregation FrameworkMongoDB Aggregation Framework
MongoDB Aggregation Framework
 
Mapping Graph Queries to PostgreSQL
Mapping Graph Queries to PostgreSQLMapping Graph Queries to PostgreSQL
Mapping Graph Queries to PostgreSQL
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the code
 
Cassandra Data Modeling
Cassandra Data ModelingCassandra Data Modeling
Cassandra Data Modeling
 
Tactical data engineering
Tactical data engineeringTactical data engineering
Tactical data engineering
 
Less08 Schema
Less08 SchemaLess08 Schema
Less08 Schema
 
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial IndexesBack to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
 
Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...Code is not text! How graph technologies can help us to understand our code b...
Code is not text! How graph technologies can help us to understand our code b...
 
Lecture 3.pdf
Lecture 3.pdfLecture 3.pdf
Lecture 3.pdf
 
PPT on Data Science Using Python
PPT on Data Science Using PythonPPT on Data Science Using Python
PPT on Data Science Using Python
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212
 

More from Jano Suchal

Slovensko.Digital: Čo ďalej?
Slovensko.Digital: Čo ďalej?Slovensko.Digital: Čo ďalej?
Slovensko.Digital: Čo ďalej?Jano Suchal
 
Improving code quality
Improving code qualityImproving code quality
Improving code qualityJano Suchal
 
Beyond search queries
Beyond search queriesBeyond search queries
Beyond search queriesJano Suchal
 
Rank all the things!
Rank all the things!Rank all the things!
Rank all the things!Jano Suchal
 
Rank all the (geo) things!
Rank all the (geo) things!Rank all the (geo) things!
Rank all the (geo) things!Jano Suchal
 
Ako si vybrať programovácí jazyk alebo framework?
Ako si vybrať programovácí jazyk alebo framework?Ako si vybrať programovácí jazyk alebo framework?
Ako si vybrať programovácí jazyk alebo framework?Jano Suchal
 
Bonetics: Mastering Puppet Workshop
Bonetics: Mastering Puppet WorkshopBonetics: Mastering Puppet Workshop
Bonetics: Mastering Puppet WorkshopJano Suchal
 
Peter Mihalik: Puppet
Peter Mihalik: PuppetPeter Mihalik: Puppet
Peter Mihalik: PuppetJano Suchal
 
Tomáš Čorej: Configuration management & CFEngine3
Tomáš Čorej: Configuration management & CFEngine3Tomáš Čorej: Configuration management & CFEngine3
Tomáš Čorej: Configuration management & CFEngine3Jano Suchal
 
Ako si vybrať programovací jazyk a framework?
Ako si vybrať programovací jazyk a framework?Ako si vybrať programovací jazyk a framework?
Ako si vybrať programovací jazyk a framework?Jano Suchal
 
SQL: Query optimization in practice
SQL: Query optimization in practiceSQL: Query optimization in practice
SQL: Query optimization in practiceJano Suchal
 
Garelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoringGarelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoringJano Suchal
 
Miroslav Šimulčík: Temporálne databázy
Miroslav Šimulčík: Temporálne databázyMiroslav Šimulčík: Temporálne databázy
Miroslav Šimulčík: Temporálne databázyJano Suchal
 
Vojtech Rinik: Internship v USA - moje skúsenosti
Vojtech Rinik: Internship v USA - moje skúsenostiVojtech Rinik: Internship v USA - moje skúsenosti
Vojtech Rinik: Internship v USA - moje skúsenostiJano Suchal
 
Profiling and monitoring ruby & rails applications
Profiling and monitoring ruby & rails applicationsProfiling and monitoring ruby & rails applications
Profiling and monitoring ruby & rails applicationsJano Suchal
 
Aký programovací jazyk a framework si vybrať a prečo?
Aký programovací jazyk a framework si vybrať a prečo?Aký programovací jazyk a framework si vybrať a prečo?
Aký programovací jazyk a framework si vybrať a prečo?Jano Suchal
 
Petr Joachim: Redis na Super.cz
Petr Joachim: Redis na Super.czPetr Joachim: Redis na Super.cz
Petr Joachim: Redis na Super.czJano Suchal
 
Metaprogramovanie #1
Metaprogramovanie #1Metaprogramovanie #1
Metaprogramovanie #1Jano Suchal
 

More from Jano Suchal (20)

Slovensko.Digital: Čo ďalej?
Slovensko.Digital: Čo ďalej?Slovensko.Digital: Čo ďalej?
Slovensko.Digital: Čo ďalej?
 
Datanest 3.0
Datanest 3.0Datanest 3.0
Datanest 3.0
 
Improving code quality
Improving code qualityImproving code quality
Improving code quality
 
Beyond search queries
Beyond search queriesBeyond search queries
Beyond search queries
 
Rank all the things!
Rank all the things!Rank all the things!
Rank all the things!
 
Rank all the (geo) things!
Rank all the (geo) things!Rank all the (geo) things!
Rank all the (geo) things!
 
Ako si vybrať programovácí jazyk alebo framework?
Ako si vybrať programovácí jazyk alebo framework?Ako si vybrať programovácí jazyk alebo framework?
Ako si vybrať programovácí jazyk alebo framework?
 
Bonetics: Mastering Puppet Workshop
Bonetics: Mastering Puppet WorkshopBonetics: Mastering Puppet Workshop
Bonetics: Mastering Puppet Workshop
 
Peter Mihalik: Puppet
Peter Mihalik: PuppetPeter Mihalik: Puppet
Peter Mihalik: Puppet
 
Tomáš Čorej: Configuration management & CFEngine3
Tomáš Čorej: Configuration management & CFEngine3Tomáš Čorej: Configuration management & CFEngine3
Tomáš Čorej: Configuration management & CFEngine3
 
Ako si vybrať programovací jazyk a framework?
Ako si vybrať programovací jazyk a framework?Ako si vybrať programovací jazyk a framework?
Ako si vybrať programovací jazyk a framework?
 
SQL: Query optimization in practice
SQL: Query optimization in practiceSQL: Query optimization in practice
SQL: Query optimization in practice
 
Garelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoringGarelic: Google Analytics as App Performance monitoring
Garelic: Google Analytics as App Performance monitoring
 
Miroslav Šimulčík: Temporálne databázy
Miroslav Šimulčík: Temporálne databázyMiroslav Šimulčík: Temporálne databázy
Miroslav Šimulčík: Temporálne databázy
 
Vojtech Rinik: Internship v USA - moje skúsenosti
Vojtech Rinik: Internship v USA - moje skúsenostiVojtech Rinik: Internship v USA - moje skúsenosti
Vojtech Rinik: Internship v USA - moje skúsenosti
 
Profiling and monitoring ruby & rails applications
Profiling and monitoring ruby & rails applicationsProfiling and monitoring ruby & rails applications
Profiling and monitoring ruby & rails applications
 
Aký programovací jazyk a framework si vybrať a prečo?
Aký programovací jazyk a framework si vybrať a prečo?Aký programovací jazyk a framework si vybrať a prečo?
Aký programovací jazyk a framework si vybrať a prečo?
 
Čo po GAMČI?
Čo po GAMČI?Čo po GAMČI?
Čo po GAMČI?
 
Petr Joachim: Redis na Super.cz
Petr Joachim: Redis na Super.czPetr Joachim: Redis na Super.cz
Petr Joachim: Redis na Super.cz
 
Metaprogramovanie #1
Metaprogramovanie #1Metaprogramovanie #1
Metaprogramovanie #1
 

Recently uploaded

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 

Recently uploaded (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

PostgreSQL: Advanced features in practice

  • 1. PostgreSQL: Advanced features in practice JÁN SUCHAL 22.11.2011 @RUBYSLAVA
  • 2. Why PostgreSQL?  The world’s most advanced open source database.  Features!  Transactional DDL  Cost-based query optimizer + Graphical explain  Partial indexes  Function indexes  K-nearest search  Views  Recursive Queries  Window Functions
  • 3. Transactional DDL class CreatePostsMigration < ActiveRecord::Migration def change create_table :posts do |t| t.string :name, null: false t.text :body, null: false t.references :author, null: false t.timestamps null: false end add_index :posts, :title, unique: true end end  Where is the problem?
  • 4. Transactional DDL class CreatePostsMigration < ActiveRecord::Migration def change create_table :posts do |t| t.string :name, null: false Column title does not exist! t.text :body, null: false is created, index is not. Oops! Table t.references :author, null: false Transactional DDL FTW! t.timestamps null: false end add_index :posts, :title, unique: true end end  Where is the problem?
  • 5. Cost-based query optimizer  What is the best plan to execute a given query?  Cost = I/O + CPU operations needed  Sequential vs. random seek  Join order  Join type (nested loop, hash join, merge join)
  • 6. Graphical EXPLAIN  pgAdmin (www.pgadmin.org)
  • 7. Partial indexes  Conditional indexes  Problem: Async job/queue table, find failed jobs  Create index on failed_at column  99% of index is never used
  • 8. Partial indexes  Conditional indexes  Problem: Async job/queue table, find failed jobs  Create index on failed_at column  99% of index is never used  Solution: CREATE INDEX idx_dj_only_failed ON delayed_jobs (failed_at) WHERE failed_at IS NOT NULL;  smaller index  faster updates
  • 9. Function Indexes  Problem: Suffix search  SELECT … WHERE code LIKE ‘%123’
  • 10. Function Indexes  Problem: Suffix search  SELECT … WHERE code LIKE ‘%123’  “Solution”:  Add reverse_code column, populate, add triggers for updates, create index on reverse_code column  reverse queries WHERE reverse_code LIKE “321%”
  • 11. Function Indexes  Problem: Suffix search  SELECT … WHERE code LIKE ‘%123’  “Solution”:  Add reverse_code column, populate, add triggers for updates, create index on reverse_code column,  reverse queries WHERE reverse_code LIKE “321%”  PostgreSQL solution: CREATE INDEX idx_reversed ON projects (reverse((code)::text) text_pattern_ops); SELECT … WHERE reverse(code) LIKE reverse(‘%123’)
  • 12. K-nearest search  Problem: Fuzzy string matching  900K rows CREATE INDEX idx_trgm_name ON subjects USING gist (name gist_trgm_ops); SELECT name, name <-> 'Michl Brla' AS dist FROM subjects ORDER BY dist ASC LIMIT 10; (312ms) "Michal Barla“ ; 0.588235 "Michal Bula“ ; 0.647059 "Michal Broz“ ; 0.647059 "Pavel Michl“ ; 0.647059 "Michal Brna“ ; 0.647059
  • 13. K-nearest search  Problem: Fuzzy string matching  900K rows  Solution: Ngram/Trigram search  johno = {" j"," jo",”hno”,”joh”,"no ",”ohn”} CREATE INDEX idx_trgm_name ON subjects USING gist (name gist_trgm_ops); SELECT name, name <-> 'Michl Brla' AS dist FROM subjects ORDER BY dist ASC LIMIT 10; (312ms) "Michal Barla“ ; 0.588235 "Michal Bula“ ; 0.647059 "Michal Broz“ ; 0.647059 "Pavel Michl“ ; 0.647059 "Michal Brna“ ; 0.647059
  • 14. K-nearest search  Problem: Fuzzy string matching  900K rows  Solution: Ngram/Trigram search  johno = {" j"," jo",”hno”,”joh”,"no ",”ohn”} CREATE INDEX idx_trgm_name ON subjects USING gist (name gist_trgm_ops); SELECT name, name <-> 'Michl Brla' AS dist FROM subjects ORDER BY dist ASC LIMIT 10; (312ms) "Michal Barla“ ; 0.588235 "Michal Bula“ ; 0.647059 "Michal Broz“ ; 0.647059 "Pavel Michl“ ; 0.647059 "Michal Brna“ ; 0.647059
  • 15. Views  Constraints propagated down to views CREATE VIEW edges AS SELECT subject_id AS source_id, connected_subject_id AS target_id FROM raw_connections UNION ALL SELECT connected_subject_id AS source_id, subject_id AS target_id FROM raw_connections;  SELECT * FROM edges WHERE source_id = 123;  SELECT * FROM edges WHERE source_id < 500 ORDER BY source_id LIMIT 10 No materialization, 2x indexed select + 1x append/merge
  • 16. Views  Constraints propagated down to views CREATE VIEW edges AS SELECT subject_id AS source_id, connected_subject_id AS target_id FROM raw_connections UNION ALL SELECT connected_subject_id AS source_id, subject_id AS target_id FROM raw_connections;  SELECT * FROM edges WHERE source_id = 123;  SELECT * FROM edges WHERE source_id < 500 ORDER BY source_id LIMIT 10  No materialization, 2x indexed select + 1x append/merge
  • 17. Recursive Queries  Problem: Find paths between two nodes in graph WITH RECURSIVE search_graph(source,target,distance,path) AS ( SELECT source_id, target_id, 1, ARRAY[source_id, target_id] FROM edges WHERE source_id = 552506 UNION ALL SELECT sg.source, e.target_id, sg.distance + 1, path || ARRAY[e.target_id] FROM search_graph sg JOIN edges e ON sg.target = e.source_id WHERE NOT e.target_id = ANY(path) AND distance < 4 ) SELECT * FROM search_graph LIMIT 100
  • 18. Recursive Queries  Problem: Find paths between two nodes in graph WITH RECURSIVE search_graph(source,target,distance,path) AS ( SELECT source_id, target_id, 1, ARRAY[source_id, target_id] FROM edges WHERE source_id = 552506 UNION ALL SELECT sg.source, e.target_id, sg.distance + 1, path || ARRAY[e.target_id] FROM search_graph sg JOIN edges e ON sg.target = e.source_id WHERE NOT e.target_id = ANY(path) AND distance < 4 ) SELECT * FROM search_graph LIMIT 100
  • 19. Recursive Queries  Problem: Find paths between two nodes in graph WITH RECURSIVE search_graph(source,target,distance,path) AS ( SELECT source_id, target_id, 1, ARRAY[source_id, target_id] FROM edges WHERE source_id = 552506 UNION ALL SELECT sg.source, e.target_id, sg.distance + 1, path || ARRAY[e.target_id] FROM search_graph sg JOIN edges e ON sg.target = e.source_id WHERE NOT e.target_id = ANY(path) AND distance < 4 ) SELECT * FROM search_graph WHERE target = 530556 LIMIT 100;
  • 20. Recursive Queries  Problem: Find paths between two nodes in graph WITH RECURSIVE search_graph(source,target,distance,path) AS ( SELECT source_id, target_id, 1, ARRAY[source_id, target_id] FROM edges WHERE source_id = 552506 UNION ALL SELECT sg.source, e.target_id, sg.distance + 1, path || ARRAY[e.target_id] FROM search_graph sg JOIN edges e ON sg.target = e.source_id WHERE NOT e.target_id = ANY(path) AND distance < 4 ) SELECT * FROM search_graph WHERE target = 530556 LIMIT 100;
  • 21. Recursive Queries  Problem: Find paths between two nodes in graph WITH RECURSIVE search_graph(source,target,distance,path) AS ( SELECT source_id, target_id, 1, ARRAY[source_id, target_id] FROM edges WHERE source_id = 552506 UNION ALL SELECT sg.source, e.target_id, sg.distance + 1, path || ARRAY[e.target_id] FROM search_graph sg JOIN edges e ON sg.target = e.source_id WHERE NOT e.target_id = ANY(path) AND distance < 4 ) SELECT * FROM search_graph WHERE target = 530556 LIMIT 100;
  • 23. Recursive queries  Graph with ~1M edges (61ms)  source; target; distance; path  530556; 552506; 2; {530556,185423,552506}  JUDr. Robert Kaliňák -> FoodRest s.r.o. -> Ing. Ján Počiatek  530556; 552506; 2; {530556,183291,552506}  JUDr. Robert Kaliňák -> FoRest s.r.o. -> Ing. Ján Počiatek  530556; 552506; 4; {530556,183291,552522,185423,552506}  JUDr. Robert Kaliňák -> FoodRest s.r.o. -> Lena Sisková -> FoRest s.r.o. -> Ing. Ján Počiatek
  • 24. Window functions  “Aggregate functions without grouping”  avg, count, sum, rank, row_number, ntile…  Problem: Find closest nodes to a given node Order by sum of path scores Path score = 0.9^<distance> / log(1 + <number of paths>) SELECT source, target FROM ( SELECT source, target, path, distance, 0.9 ^ distance / log(1 + COUNT(*) OVER (PARTITION BY distance,target) ) AS score FROM ( … ) AS paths ) as scored_paths GROUP BY source, target ORDER BY SUM(score) DESC
  • 25. Window functions  “Aggregate functions without grouping”  avg, count, sum, rank, row_number, ntile…  Problem: Find closest nodes to a given node  Order by sum of path scores  Path score = 0.9^<distance> / log(1 + <number of paths>) SELECT source, target FROM ( SELECT source, target, path, distance, 0.9 ^ distance / log(1 + COUNT(*) OVER (PARTITION BY distance,target) ) AS score FROM ( … ) AS paths ) as scored_paths GROUP BY source, target ORDER BY SUM(score) DESC
  • 26. Window functions  “Aggregate functions without grouping”  avg, count, sum, rank, row_number, ntile…  Problem: Find closest nodes to a given node  Order by sum of path scores  Path score = 0.9^<distance> / log(1 + <number of paths>) SELECT source, target FROM ( SELECT source, target, path, distance, 0.9 ^ distance / log(1 + COUNT(*) OVER (PARTITION BY distance, target) ) AS n FROM ( … ) AS paths ) as scored_paths GROUP BY source, target ORDER BY SUM(score) DESC
  • 27. Window functions  “Aggregate functions without grouping”  avg, count, sum, rank, row_number, ntile…  Problem: Find closest nodes to a given node  Order by sum of path scores  Path score = 0.9^<distance> / log(1 + <number of paths>) SELECT source, target FROM ( SELECT source, target, path, distance, 0.9 ^ distance / log(1 + COUNT(*) OVER (PARTITION BY distance, target) ) AS score FROM ( … ) AS paths ) as scored_paths GROUP BY source, target ORDER BY SUM(score) DESC
  • 28. Window functions  “Aggregate functions without grouping”  avg, count, sum, rank, row_number, ntile…  Problem: Find closest nodes to a given node  Order by sum of path scores  Path score = 0.9^<distance> / log(1 + <number of paths>) SELECT source, target FROM ( SELECT source, target, path, distance, 0.9 ^ distance / log(1 + COUNT(*) OVER (PARTITION BY distance, target) ) AS score FROM ( … ) AS paths ) AS scored_paths GROUP BY source, target ORDER BY SUM(score) DESC
  • 29. Window functions  Example: Closest to Róbert Kaliňák "Bussines Park Bratislava a.s." "JARABINY a.s." "Ing. Robert Pintér" "Ing. Ján Počiatek" "Bratislava trade center a.s.“ …  1M edges, 41ms
  • 30. Additional resources  www.postgresql.org  Read the docs, seriously  www.explainextended.com  SQL guru blog  explain.depesz.com  First aid for slow queries  www.wikivs.com/wiki/MySQL_vs_PostgreSQL  MySQL vs. PostgreSQL comparison
  • 31. Real World Explain  www.postgresql.org