> After trying both against the real tables DISTINCT ON seems to be > about two orders of magnitude faster than the other options. Glad it worked. It looked at least naively similar to situations I've run into and DISTINCT ON always helped me out. It's all the fun of GROUP BY with the ability to discard non-aggregate results just by screwing around with your sorting. Still one of my favorite tricks. -- Shaun Thomas Peak6 | 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