Re: seq scan in the case of max() on the primary key column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/17/2011 06:22 AM, Svetlin Manavski wrote:

Shaun, that solution is brilliant.

Don't thank me. I actually got the basic idea from a post here a couple years ago. The only difference is I formalized it somewhat and put it in our utility schema, where I put lots of other random useful stored procs I've accumulated over the years. I have another one that works with dates. :)

I assume you already modified it by removing the 'utility' schema prefix from the recursive call. The recursive call is in case the child tables are themselves used as a template for further inheritance. It's rare, but possible. This function will always get you the max value on a column in a series of partitioned tables, and quickly so long as it's indexed.

It's a bit of a hack, but it's worked fine for us while we wait for the planner to catch up. :)

--
Shaun Thomas
OptionsHouse | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604
312-676-8870
sthomas@xxxxxxxxx

______________________________________________

See  http://www.peak6.com/email_disclaimer.php
for terms and conditions related to this email

--
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux