Re: [SQL] triple self-join crawling

2007-03-19 Thread Martin Marques
T E Schmitz escribió: QUERY PLAN GroupAggregate (cost=1370368.19..1435888.88 rows=5801 width=56) (actual time=11945.030..13163.156 rows=5801 loops=1) -> Sort (cost=1370368.19..1379715.86 rows=3739067 width=56) (actual time=11944.753..12462.623 rows=120117 loops=1) Sort Key: histo

Re: [SQL] triple self-join crawling

2007-03-19 Thread T E Schmitz
Andrew Sullivan wrote: Define "crawling". Also, please post EXPLAIN and, if feasible, Total runtime: 191430.537 ms EXPLAIN ANALYSE output for your case. On Sun, Mar 18, 2007 at 07:51:28PM +, T E Schmitz wrote: The following self join of a table containing 5800 records is crawling:

Re: [SQL] triple self-join crawling

2007-03-19 Thread T E Schmitz
T E Schmitz wrote: T E Schmitz wrote: Things improved hugely when I changed the JOIN clauses: see explain analyze below - can this be improved further? LEFT OUTER JOIN history AS past_month ON (past_month.stock = history.stockAND past_month.day >= (history.day - 30) AND past_month

Re: [SQL] triple self-join crawling

2007-03-19 Thread T E Schmitz
T E Schmitz wrote: The following self join of a table containing 5800 records is crawling: SELECT history.stock, history.day, history.high, history.low, MAX(past_week.high) AS week_high, MAX(past_month.high) AS month_high FROM history INNER JOIN history AS past_month ON (past_month.s

Re: [SQL] triple self-join crawling

2007-03-19 Thread Andrew Sullivan
Define "crawling". Also, please post EXPLAIN and, if feasible, EXPLAIN ANALYSE output for your case. A On Sun, Mar 18, 2007 at 07:51:28PM +, T E Schmitz wrote: > The following self join of a table containing 5800 records is crawling: > > CREATE TABLE history > ( > stock VARCHAR(30) NOT

[SQL] triple self-join crawling

2007-03-18 Thread T E Schmitz
The following self join of a table containing 5800 records is crawling: CREATE TABLE history ( stock VARCHAR(30) NOT NULL, day date NOT NULL, open NUMERIC (6,1) NOT NULL, high NUMERIC (6,1) NOT NULL, low NUMERIC (6,1) NOT NULL, close NUMERIC (6,1) NOT NULL, volume NUME