Re: When to store data that could be derived

From: Frank <frank(at)chagford(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: When to store data that could be derived
Date: 2019-03-25 15:11:22
Message-ID: 86948961-6869-c5c3-ee40-0ffaaf2d46be@chagford.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2019-03-25 4:06 PM, Ron wrote:
> On 3/25/19 8:15 AM, Frank wrote:
>
> It would be interesting to see what the query planner tries to do with
> this:
>
> WHERE
>     CASE
>         WHEN a.tran_type = 'ar_rec' THEN y.posted
>         WHEN a.tran_type = 'cb_rec' THEN w.posted
>     END = '1'
>

I have attached the schema showing the full VIEW definition, and the
result of the following EXPLAIN -

EXPLAIN SELECT * FROM ccc.ar_trans WHERE cust_row_id = 4 AND tran_date
BETWEEN '2015-06-01' AND '2015-06-30'.

Because I have used 'WHERE tran_date' in the query, and tran_date is
also derived from a CASE expression, I imagine that will also add some
complication.

I am running PostgreSQL 11.1 on Fedora 29.

Frank

Attachment Content-Type Size
schema text/plain 2.4 KB
explain text/plain 4.2 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Frank 2019-03-25 15:44:21 Re: When to store data that could be derived
Previous Message Ron 2019-03-25 14:06:16 Re: When to store data that could be derived