Re: Can WINDOW be used?

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Greg Spiegelberg <gspiegelberg(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Can WINDOW be used?
Date: 2010-08-13 21:17:02
Message-ID: 4C65B64E.9070005@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


> wxd0812=# EXPLAIN ANALYZE
> wxd0812-# SELECT * FROM
> wxd0812-# (SELECT DISTINCT ON (key1_id,key2_id) * FROM sid120.data
> ORDER BY key1_id,key2_id,time_id DESC) x
> wxd0812-# WHERE NOT deleted;

SELECT * FROM (
SELECT data.*,
rank() as rank over
( partition by key1_id, key2_id order by time_id DESC )
FROM data
) as rankings
WHERE rank = 1 AND NOT deleted;

--
-- Josh Berkus
PostgreSQL Experts Inc.
http://www.pgexperts.com

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Scott Carey 2010-08-16 16:28:52 Re: Advice configuring ServeRAID 8k for performance
Previous Message Greg Smith 2010-08-13 18:41:29 Re: Advice configuring ServeRAID 8k for performance