Re: [PATCH] Equivalence Class Filters

From: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Equivalence Class Filters
Date: 2015-12-16 01:20:27
Message-ID: 5670BC5B.5040707@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12/16/2015 01:26 AM, Simon Riggs wrote:
>
> There is an interesting real world case where we might get some use of
> these thoughts.
>
> If we have Orders and OrderItems (FK->Orders)
> and we also know (and can Assert) Order.order_date <= OrderItems.ship_date
> then a restriction on Orders.order_date > X => OrderItem.ship_date > X
> when the two tables are joined on OrderId
> and also a restriction on OrderItems.ship_date >= X => Orders.order_date
> < X when the two tables are joined on OrderId
>
> Such an assertion could be checked during the FK check, so would not be
> expensive to maintain.
>
> One for the future, at least, since we don't have any way of expressing
> or enforcing that just yet.

There's a concept of "correlation maps", described in a paper [1]
presented on VLDB 2009. It essentially talks about deriving conditions
between attributes of the same table, but I guess it might be modified
to track the correlations through foreign keys.

Interestingly enough, the data for the paper paper were collected on
PostgreSQL, but the correlation maps were implemented in an application
layer on top of the database.

[1] http://www.vldb.org/pvldb/2/vldb09-199.pdf

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2015-12-16 01:51:30 Re: Fixing warnings in back branches?
Previous Message David Rowley 2015-12-16 00:27:41 Re: Performance improvement for joins where outer side is unique