table partitioning and select max(id)

From: Tobias Brox <tobixen(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: table partitioning and select max(id)
Date: 2011-02-04 23:24:44
Message-ID: AANLkTi=pzBtH4i_WYrbR9JEyq+49vPPVJf-q08z_Bhu=@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

I implemented table partitioning, and it caused havoc with a "select
max(id)" on the parent table - the query plan has changed from a
lightningly fast backwards index scan to a deadly seq scan. Both
partitions are set up with primary key index and draws new IDs from
the same sequence ... "select max(id)" on both partitions are fast.
Are there any tricks I can do to speed up this query? I can't add the
ID to the table constraints, we may still get in "old" data causing
rows with fresh IDs to get into the old table.

(I decided to keep this short rather than include lots of details -
but at least worth mentioning that we're using PG9)

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Mark Kirkwood 2011-02-04 23:44:19 Re: Talking about optimizer, my long dream
Previous Message Bruce Momjian 2011-02-04 23:17:12 Re: [HACKERS] Slow count(*) again...