Partition and Functions

From: Leandro Guimarães <leo(dot)guimaraes(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Partition and Functions
Date: 2019-02-22 13:29:31
Message-ID: CAJV35FOECWbh4mh=QGb8k2S3t8eszuj9GRB6WdhMpYfUYwH4=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Everyone,
I have a partitioned by period table scenario here where I need to
execute a query with a function in where clause.

I'm not sure if this is the best approach to do that, but when I use the
functions, it scans all the tables instead only the desired one. If I put
the parameter hardcoded, it works fine.

Any idea how could I solve this? Follow my query example:

SELECT customer_id,
date_id,
kpi AS kpi_value
FROM schema1.table1
WHERE date_id >= *To_char*(( current_date - interval '30' day ) :: DATE,
'YYYYMMDD')::INTEGER

Thanks!
Leandro Guimarães

Browse pgsql-general by date

  From Date Subject
Next Message Derek Hans 2019-02-22 14:44:05 Update does not move row across foreign partitions in v11
Previous Message github kran 2019-02-22 12:46:57 Re: How many billion rows of data I can store in PostgreSQL RDS.