[PERFORM] Window functions, partitioning, and sorting performance

2014-08-21 Thread Eli Naeher
I have a table called stop_event (a stop event is one bus passing one bus stop at a given time for a given route and direction), and I'd like to get the average interval for each stop/route/direction combination. A few hundred new events are written to the table once every minute. No rows are

Re: [PERFORM] Window functions, partitioning, and sorting performance

2014-08-21 Thread Eli Naeher
the whole table, even though I have indexes on both id and previous_stop_event: http://explain.depesz.com/s/ctck. Any idea why those indexes are not being used? Thank you again, -Eli On Thu, Aug 21, 2014 at 9:05 AM, Shaun Thomas stho...@optionshouse.com wrote: On 08/21/2014 08:29 AM, Eli Naeher wrote

Re: [PERFORM] Window functions, partitioning, and sorting performance

2014-08-21 Thread Eli Naeher
Oops, I forgot to include the test self-join query I'm using. It is simply: SELECT se1.stop_time AS curr, se2.stop_time AS prev FROM stop_event se1 JOIN stop_event se2 ON se1.previous_stop_event = se2.id; On Thu, Aug 21, 2014 at 11:19 AM, Eli Naeher enae...@gmail.com wrote: Upping work_mem

[PERFORM] Help me understand why my subselect is an order of magnitude faster than my nested joins

2014-03-05 Thread Eli Naeher
Hello, I have two versions of essentially the same query; one using nested joins, the other using subselects. The version using the subselect is roughly an order of magnitude faster (~70ms on my box and data vs ~900ms for the nested joins). Of course the obvious answer here is just to use the

[PERFORM] Subselect an order of magnitude faster than nested joins

2014-03-03 Thread Eli Naeher
Hello, I have two versions of essentially the same query; one using nested joins, the other using subselects. The version using the subselect is roughly an order of magnitude faster (~70ms on my box and data vs ~900ms for the nested joins). Of course the obvious answer here is just to use the