Partitions not Working as Expected BY: LLOYD ALBIN 8/6/2013.

Slides:



Advertisements
Similar presentations
s, Texts or Social Networking By Josie Hayden.
Advertisements

Hive Security Yongqiang He Software Engineer Facebook Data Infrastructure Team.
PROOF BY CONTRADICTION
08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Finding and Reporting Postgres Bug #8257 BY: LLOYD ALBIN 8/6/2013.
SQL Injection Attacks Prof. Jim Whitehead CMPS 183: Spring 2006 May 17, 2006.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 8-1 COS 346 Day 17.
A Structure Editor For PAL Constraints Anton An July 18, 2001.
Static and Dynamic Behavior Fall 2005 OOPD John Anthony.
SQL Injection Attacks CS 183 : Hypermedia and the Web UC Santa Cruz.
Keystone Problems… Keystone Problems… next Set 19 © 2007 Herbert I. Gross.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Databases with PHP A quick introduction. Y’all know SQL and Databases  You put data in  You get data out  You can do processing on it very easily 
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
Warm-up Solve for missing variable: 1)(14√2)² = 14² + b² 2)A = (b1 + b2)h/2; for b1.
What is Validation Understanding Validation (Different from Verification)
Do Now Today’s Title: Making Assertions In your notebook, get ready for a practice quiz: ◦ Title: Practice Quiz for Citations ◦ Number it #1-5.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
Errors And How to Handle Them. GIGO There is a saying in computer science: “Garbage in, garbage out.” Is this true, or is it just an excuse for bad programming?
1 Basic Perl CGI Programming. 2 Issues How and when your program is invoked. Generating Response –HTTP Headers –HTML (or whatever document type you want)
CS 350, slide set 5 M. Overstreet Old Dominion University Spring 2005.
© A. Kwasinski, 2014 ECE 2795 Microgrid Concepts and Distributed Generation Technologies Spring 2015 Week #7.
Fundamental Programming: Fundamental Programming Introduction to C++
* Students will Use the Converse of the Pythagorean Theorem to solve problems. * Use side lengths to classify triangles by their angle measures. * Why?
COP Structures Instructor: Diego Rivera-Gutierrez I’m back baby!
Prepared By Aakanksha Agrawal & Richa Pandey Mtech CSE 3 rd SEM.
An Alternative Plan Virgil Bierschwale. Redesign Effort? In the “Outline of Redesign Effort” proposal that I received from Scott Henson, we find a massive.
Algorithms & FlowchartsLecture 10. Algorithm’s CONCEPT.
ISBN Chapter 3 Describing Semantics.
Li Tak Sing COMPS311F. Database programming JDBC (Java Database Connectivity) Java version of ODBC (Open Database Connectivity) ODBC provides a standard.
Session Objectives Reserved Words and Object type Conditional Usage of Reserved Words Usage of Conditional Logic 2.
Connect with life Nauzad Kapadia Quartz Systems
CS 101 – Nov. 11 Finish Database concepts –1-1 relationship –1-many relationship –Many-to-many relationship Review.
9.3 The Converse of the Pythagorean Theorem
Written by: Dr. JJ Shepherd
CSD 340 (Blum)1 For Loops See Beginning JavaScript (Paul Wilton) p. 87.
SQL Injection Attacks An overview by Sameer Siddiqui.
Lecture PowerPoint Slides Basic Practice of Statistics 7 th Edition.
Summary My spreadsheet shows that most people send over 100 texts a day. It also shows that most people don’t talk for more than 30 minutes a day. Everyone.
Defensive Programming. Good programming practices that protect you from your own programming mistakes, as well as those of others – Assertions – Parameter.
PHY 107 – Programming For Science. Today’s Goal  How to use while & do / while loops in code  Know & explain when use of either loop preferable  Understand.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
ADVANCED SQL.  The SQL ORDER BY Keyword  The ORDER BY keyword is used to sort the result-set by one or more columns.  The ORDER BY keyword sorts the.
Loop Design What goes into coding a loop. Considerations for Loop Design ● There are basically two kinds of loops: ● Those that form some accumulated.
 Understand why schools ask students to give presentations.  Understand what makes a good presentation.  Learn about structuring a presentation. 
Presented by Alexey Vedishchev Developing Web-applications with Grails framework American University of Nigeria, 2016 Form Submission And Saving Data To.
Partitioning & Creating Hardware Tablespaces for Performance
SQL Injection Attacks.
COMP 430 Intro. to Database Systems
Presented by: Teererai Marange
Propositional Logic Session 3
This shows the user interface and the SQL Select for a situation with two criteria in an AND relationship.
Essay Writing and Leveled Readings
TDD Overview CS 4501/6501 Software Testing
SQL – Dates and Times.
Error Handling Summary of the next few pages: Error Handling Cursors.
1Z0-148 Dumps Oracle Database 12c: Advanced PL/SQL Exam Just 1 day study required to pass exam 100% Passing Assurance.
9.3 The Converse of the Pythagorean Theorem
From 4 Minutes to 8 Seconds in an Hour (or a bit less)
SQL – Parameterized Queries
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Database Design and Development
The PROCESS of Queries John Deardurff Website: ThatAwesomeTrainer.com
Equations with One Solution, No Solution, and Infinitely Many Solutions 6x + 3 = 5x + 7 6x + 3 = 6x + 7 6x + 3 = 6x + 3.
Focus of the Course Object-Oriented Software Development
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Combining Like Terms.
Presentation transcript:

Partitions not Working as Expected BY: LLOYD ALBIN 8/6/2013

The Problem I found this issue posted on the pgsql-performance mailing list and decided to verify the problem since we use partitions in our database. My tanks to Shaun for exposing this issue. Shaun Thomas OptionsHouse | 141 W. Jackson Blvd. | Suite 500 | Chicago IL, sthomas(at)optionshouse(dot)com

Creating the tables We first create the parent table and then two child tables. The child tables have check constraints to limit what data may be added to the child table and to help the query optimizer to know if this table should be part of the query or not when querying the parent table. CREATE TABLE part_test ( fake INT, part_col TIMESTAMP WITHOUT TIME ZONE ); CREATE TABLE part_test_1 ( CHECK (part_col >= ' ' AND part_col < ' ') ) INHERITS (part_test); CREATE TABLE part_test_2 ( CHECK (part_col >= ' ' AND part_col < ' ') ) INHERITS (part_test);

Usage of the check constraint in your query If you hard code your date into your query, then it uses the correct child partition for your query. EXPLAIN SELECT * FROM part_test WHERE part_col > ' ';

The problem We find that where we think it should have used the correct child table, it instead use all the child tables, ignoring the check constraints. As a dba we tell the developers to use Postgres as much as possible instead of their programming language. EXPLAIN SELECT * FROM part_test WHERE part_col > CURRENT_DATE;

Additional issues While these were not tested/reported, they will also fail as I found out during my testing. SELECT * FROM part_test WHERE part_col > NOW(); SELECT * FROM part_test WHERE part_col > date_trunc(‘month’, NOW());

Talking about the issue. This is one of the many responses. This one by Tom Lane. The long and the short of the issue is that the DATE/TIME functions can change over time or even be different between when you prepare a statement and execute the statement so they will always scan all the child tables. I don't see any very good solution to your problem within the current approach to partitioning, which is basically theorem-proving. That proof engine has no concept of time passing, let alone the sort of detailed knowledge of the semantics of this particular function that would allow it to conclude "if CURRENT_DATE > ' ' is true now, it will always be so in the future as well".

The solution We all hate this solution for a fix for this will be a long ways off as they say the whole engine will have to be re-written to support a fix. The only current solution is to hard code your date/timestamp into your query where your programming language submits the current date/timestamp as a text string instead of using the system variables.