agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Jan Ostrochovsky <jan.ostrochovsky@mobiletech.sk>
To: Metatrader EA <metatraderea@gmail.com>
Cc: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: Dynamic queries for Partitions
Date: Thu, 24 Nov 2016 10:22:49 +0100 (CET)
Message-ID: <1685623271.4216209.1479979369717.JavaMail.zimbra@mobiletech.sk> (raw)
In-Reply-To: <CAJNXAk2G_UBPXdji3bwRyDSPGJHms10wBC-jZ80PSm30tWGaZg@mail.gmail.com>
References: <CAJNXAk2G_UBPXdji3bwRyDSPGJHms10wBC-jZ80PSm30tWGaZg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

Hello Bill, 

if I understand correctly, you need to have constraint exclusion turned on and be careful about types - types in WHERE condition should be the same as those with CHECK constraint in partitioned table. Then you won't need 2 steps, but just one - one SELECT from master table fits all. Details are in the PostgreSQL documentation (Partitioning). 

Jano 

> From: "Metatrader EA" <metatraderea@gmail.com>
> To: "pgsql-sql" <pgsql-sql@postgresql.org>
> Sent: Wednesday, 23 November, 2016 15:54:03
> Subject: [SQL] Dynamic queries for Partitions

> Hi,

> When I run one query on one partitioned table.

> Select * from customer where opendate = (date_trunc('month', current_date)+'11
> days'::interval)::date ;

> This query will do that postgres will check all my partitions.

> How can I do ?

> Step 1 generate one sql that will be like "Select * from customer where opendate
> = '2016-11-01' ;

> Step 2 :: Then run code from step1.

> Any advice?

> //Bill

view thread (2+ messages)

Message-ID: <1685623271.4216209.1479979369717.JavaMail.zimbra@mobiletech.sk>
Permalink:  ../1685623271.4216209.1479979369717.JavaMail.zimbra@mobiletech.sk/
Also on:    postgresql.org/message-id/1685623271.4216209.1479979369717.JavaMail.zimbra@mobiletech.sk

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jan.ostrochovsky@mobiletech.sk, metatraderea@gmail.com
  Subject: Re: Dynamic queries for Partitions
  In-Reply-To: <1685623271.4216209.1479979369717.JavaMail.zimbra@mobiletech.sk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox