Обсуждение: Partition and Functions

Поиск
Список
Период
Сортировка

Partition and Functions

От
Leandro Guimarães
Дата:
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