📔
Databases
  • Table of contents
  • SQL
    • Getting Started
      • PgAdmin Tool
    • Data Types
      • Arrays
      • Date/Time/Stamps
      • JSON
      • Internal Functions
      • Sequences
      • User Defined Data Types
    • Database
      • Schema
    • Table
      • Aggregation
      • Usefull Functions
      • Combining Tables
      • Constraints
      • Common Table Expression
      • GROUP BY and HAVING
      • OPERATORS
      • ORDER BY and DISTINCT
      • Views
      • WHERE Clause
    • Order of SQL Execution
    • Advance Table
      • Internals
      • Managing Tables
      • Partitioning Tables
      • Pivotal or Crosstab Tables
    • Joins
      • Cross & Natural Joins
      • Full, Multiple & Self Joins
      • Inner Join
      • Left and Right JOIN
    • Functions
      • Cursors
      • PL/pgSQL
      • Stored Procedures
      • Triggers
        • More on Triggers
    • Indexing
      • Custom Indexes
      • GIN Index
      • Indexes
      • SQL
      • Unique Index
    • Summarization
      • SubQueries
      • Window
  • MongoDB
    • Mongo Administration
    • MongoDB Aggregation
    • MQL
  • Redis
  • Cassandra
    • CQL
    • Data Modelling
      • Advance Data Modelling
    • Cassandra Administration
    • Cassandra Features
Powered by GitBook
On this page
  • Lifetime of Query
  • Optimiser
  • Scan Nodes
  • Sequential Scan
  • Index Scan
  • Index only scan
  • Hash Join

Was this helpful?

  1. SQL
  2. Indexing

SQL

Lifetime of Query

  • Parser : handles the textual form of the statement and verifies whether it is correct or not

  • Re-writer : applying the syntactic rules to rewrite the original SQL statement.

  • Optimiser : finding the fastest path to the data

  • Executor : responsible for effectively going to the storage and retrieving the data from the physical storage.

Optimiser

  • Finds all the paths and gets the path with cheapest COST

  • LOWEST COST WINS !!

Scan Nodes

  • Nodes are available for :

    • every operation

    • every access methods

  • Nodes are stack-able

    • Parent Node ( cost = 0.00 ... )

      • Child Node

        • Child Node

  • Types of Nodes

    • Sequential Scan

    • Index Scan, Index Only Scan, Bitmap Index Scan

    • Nested Loop, Hash Join and Merge Join

    • Gather and Merge parallel nodes

    Get All Node Types : SELECT * FROM pg_am;

Sequential Scan

Performs a sequential scan on the whole table.

Index Scan

  • Index is used to access Data

  • Types

    • Index scan

    • Index only scan

    • Bitmap Index

Index only scan

Hash Join

  • Used when joining tables

  • Joins preformed on 2 table at a time, if more tables are joined together, the output at one join in treated as input to a subsequent join

  • When joining large number of tables, the genetic query optimiser settings may effect what combinations of joins are considered.

Types

  • Inner Table : Build a hash table from the inner table, keyed by the join key.

  • Outer Table : then scan the outer table checking if a corresponding value is present

Memory Size ( used by sort operation and hash table ) : 4 MB

PreviousIndexesNextUnique Index

Last updated 2 years ago

Was this helpful?

image
image
image
image