Code Monkey home page Code Monkey logo

danolivo / pgdev Goto Github PK

View Code? Open in Web Editor NEW

This project forked from postgres/postgres

3.0 3.0 0.0 550.35 MB

My experiments with mirror of the official PostgreSQL GIT repository.

Home Page: http://www.postgresql.org/

License: Other

Emacs Lisp 0.01% Makefile 0.66% M4 0.35% Shell 0.14% C 85.00% PLpgSQL 6.63% Perl 4.06% C++ 0.06% Yacc 1.25% Lex 0.41% Ruby 0.53% Python 0.10% Assembly 0.01% Roff 0.03% sed 0.01% DTrace 0.01% XS 0.01% PLSQL 0.10% Meson 0.65% Starlark 0.01%

pgdev's People

Contributors

adunstan avatar akorotkov avatar alvherre avatar anarazel avatar bmomjian avatar danielgustafsson avatar david-rowley avatar deanrasheed avatar feodor avatar hlinnaka avatar j-naylor avatar jconway avatar jeff-davis avatar kgrittn avatar macdice avatar masaofujii avatar mhagander avatar michaelpq avatar nathan-bossart avatar nmisch avatar petere avatar petergeoghegan avatar robertmhaas avatar scrappy avatar sfrost avatar simonat2ndquadrant avatar tatsuo-ishii avatar tglsfdc avatar tvondra avatar vadim4o avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pgdev's Issues

Logical additions to physical time

We use physical time to create timestamp. But we correct it with some type of logical time (not wait for timeout) in the case of any problems. Analyze and test this aspect of our implementation.

ERROR: CTE in subquery, references upper relation

ERROR: plan should not reference subplan's variable

Replay:
EXPLAIN (COSTS OFF)
SELECT * FROM subselect_tbl a
WHERE a.f1 IN (
WITH cte AS (
SELECT * FROM subselect_tbl c WHERE f1 < 42 AND f2 = a.f1
)
SELECT b.f2 FROM cte b WHERE b.f2 = a.f2 AND b.f2 < 12
)
;

Check possible complex expressions in a target list of an unnesting subquery

	querytree->hasAggs ||
	querytree->hasWindowFuncs ||
	querytree->hasTargetSRFs ||
	querytree->hasSubLinks ||
	querytree->cteList ||
	querytree->rtable ||
	querytree->jointree->fromlist ||
	querytree->jointree->quals ||
	querytree->groupClause ||
	querytree->groupingSets ||
	querytree->havingQual ||
	querytree->windowClause ||
	querytree->distinctClause ||
	querytree->sortClause ||
	querytree->limitOffset ||
	querytree->limitCount ||
	querytree->setOperations ||

Snapshot too old

In many tests on AWS we cought the error "Snapshot too old". In all tests difference in time was 5 seconds. It may be a bug. But it may be an internal problem of AWS clocks.

Theoretical options for SJR

Techniqiues:
2. INNER JOIN Elimination
3. OUTER JOIN Elimination
4. OUTER JOIN Elimination with DISTINCT

Which of these techniques implemented (or can be possible implemented with our approach)?

Advantages:

  • Performance
  • More precise cardinality estimation
  • Less number of entities at the stage of optimizing

Disadvantages

  • Overhead variants:
  1. we have many self joins but no one can be removed
  2. we have many joins, but no one SJ exist
  3. pricey procedure of SJ elimination

See:

  1. Implementation of Two Semantic Query Optimization Techniques in DB2 Universal Database
    https://www.researchgate.net/publication/221309776_Implementation_of_Two_Semantic_Query_Optimization_Techniques_in_DB2_Universal_Database
  2. https://blog.jooq.org/join-elimination-an-essential-optimiser-feature-for-advanced-sql-usage/

Small questions on corner cases of SJ detection

explain (COSTS OFF)
SELECT * FROM pg_am am WHERE am.amname IN (
  SELECT c1.relname AS relname
  FROM pg_class c1
    JOIN pg_class c2
    ON c1.oid=c2.oid AND c1.oid < 10
	JOIN pg_class c3 ON (c3.oid = c2.oid)
);

Result is OK:

 Hash Semi Join
   Hash Cond: (am.amname = c3.relname)
   ->  Seq Scan on pg_am am
   ->  Hash
         ->  Index Scan using pg_class_oid_index on pg_class c3
               Index Cond: ((oid < '10'::oid) AND (oid IS NOT NULL))

Query N0.2:

explain (COSTS OFF)
SELECT * FROM pg_am am WHERE am.amname IN (
  SELECT c1.relname AS relname
  FROM pg_class c1
    JOIN pg_class c2
    ON c1.oid=c2.oid AND c1.oid < 10
	JOIN pg_class c3 ON (c1.oid = 1 AND c3.oid = 1)
);

No one JOIN was deleted:

 Nested Loop Semi Join
   Join Filter: (am.amname = c1.relname)
   ->  Seq Scan on pg_am am
   ->  Materialize
         ->  Nested Loop
               ->  Nested Loop
                     ->  Index Scan using pg_class_oid_index on pg_class c1
                           Index Cond: ((oid < '10'::oid) AND (oid = '1'::oid))
                     ->  Index Only Scan using pg_class_oid_index on pg_class c2
                           Index Cond: (oid = '1'::oid)
               ->  Index Only Scan using pg_class_oid_index on pg_class c3
                     Index Cond: (oid = '1'::oid)

Query N0.3:

SELECT * FROM pg_am am WHERE am.amname IN (
  SELECT c1.relname AS relname
  FROM pg_class c1
    JOIN pg_class c2
    ON c1.oid=c2.oid AND c1.oid < 10
      JOIN pg_class c3 ON (c3.oid = 1 AND c1.oid = 1)
);

Only one JOIN was deleted:

  Nested Loop Semi Join
    Join Filter: (am.amname = c2.relname)
    ->  Seq Scan on pg_am am
    ->  Materialize
          ->  Nested Loop
                ->  Index Scan using pg_class_oid_index on pg_class c2
                      Index Cond: ((oid < '10'::oid) AND (oid IS NOT NULL))
                ->  Index Only Scan using pg_class_oid_index on pg_class c3
                      Index Cond: (oid = '1'::oid)

violated rule: "xact confirmed as committed, so any following xact must see its effects"

Currently, the rule "xact confirmed as committed, so any following xact must see its effects" might be violated.
Example:
Time(node1) >> Time(node2)
user executes transaction No.1 at node1 with time=10, update data at node1 and node2 and commit.
The same user start transaction No.2 at node2 with time=5 and can't see changes of committed (user done this sometimes ago) transaction.
Maybe it is not a problem of distributed DBMS? Maybe we should consider this as a feature of distributed transactions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.