Re: Table performance with millions of rows (partitioning)

From: pinker <pinker(at)onet(dot)eu>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Table performance with millions of rows (partitioning)
Date: 2017-12-28 02:22:14
Message-ID: 1514427734055-0.post@n3.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

No, it's unfortunately not possible.
Documentation says in Caveats part:

/Constraint exclusion only works when the query's WHERE clause contains
constants (or externally supplied parameters). For example, a comparison
against a non-immutable function such as CURRENT_TIMESTAMP cannot be
optimized, since the planner cannot know which partition the function value
might fall into at run time.

Keep the partitioning constraints simple, else the planner may not be able
to prove that partitions don't need to be visited. Use simple equality
conditions for list partitioning, or simple range tests for range
partitioning, as illustrated in the preceding examples. A good rule of thumb
is that partitioning constraints should contain only comparisons of the
partitioning column(s) to constants using B-tree-indexable operators./

Even making a function in SQL or plpgsql and declaring it as immutable will
not help. Postgres will always check against all the partitions. It's not
enough "simple" for the planner.

--
Sent from: http://www.postgresql-archive.org/PostgreSQL-performance-f2050081.html

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Robert Blayzor 2017-12-30 04:37:56 partitioning an existing table
Previous Message Robert Blayzor 2017-12-28 01:27:08 Re: Table performance with millions of rows (partitioning)