Re: Postgresql partitioning - single hot table or distributed

From: Greg Smith <greg(at)2ndquadrant(dot)com>
To: Vick Khera <vivek(at)khera(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Postgresql partitioning - single hot table or distributed
Date: 2010-07-02 13:43:40
Message-ID: 4C2DED0C.7090800@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vick Khera wrote:
> The drawback to partitioning by an ID number using modulo is that for
> constraint exclusion to work you have to actually add something like
> "AND (my_id % 42) = 0" to match the constraint. The exclusion is not
> done by executing the constraint, but by proving the constraint will
> hold true for the WHERE clause.

Vick's "Case study of partitioning a large table in Postgres 8"
presentation at http://www.mailermailer.com/labs/presentations/index.rwp
covers this topic in more detail. The important thing to realize is
that your partitioning scheme must respect the limitations of the
constraint exclusion code in the query planner to be most useful. You
really need to consider not just the structure of the data, but what the
queries against it look like, to make that call. If you can hack the
application to include the modulo bit in every query that might be a
sufficient breakdown for you. But you have to consider what that looks
like from the query side, given what the optimizer knows how to do, not
just the perspective of the table structure. Building a quick prototype
and using EXPLAIN ANALYZE of common queries is invaluable here to do an
early investigation of any potential redesign.

--
Greg Smith 2ndQuadrant US Baltimore, MD
PostgreSQL Training, Services and Support
greg(at)2ndQuadrant(dot)com www.2ndQuadrant.us

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Saitenheini 2010-07-02 13:45:50 C-functions using SPI Missing Magic Block Error
Previous Message Saitenheini 2010-07-02 13:26:43 C-Functions using SPI - Missing Magic Block