pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Martin Marques <martin@bugs.unl.edu.ar>
To: mailreg@numerixtechnology.de
Cc: pgsql-sql@postgresql.org
Subject: Re: triple self-join crawling
Date: Mon, 19 Mar 2007 19:00:21 -0300
Message-ID: <45FF07F5.4020204@bugs.unl.edu.ar> (raw)
In-Reply-To: <45FEB611.8070606@numerixtechnology.de>
References: <45FD9840.4040305@numerixtechnology.de>
	<45FE4848.5040407@numerixtechnology.de>
	<45FEB611.8070606@numerixtechnology.de>

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: history.stock, history."day", history.high, history.low
>         ->  Hash Left Join  (cost=160.02..391554.63 rows=3739067 
> width=56) (actual time=52.746..3778.409 rows=120117 loops=1)
>               Hash Cond: ((("outer".stock)::text = 
> ("inner".stock)::text) AND ("outer"."day" = "inner"."day"))
>               Join Filter: ("inner"."day" >= ("outer"."day" - 7))
>               ->  Nested Loop Left Join  (cost=0.00..204441.26 
> rows=3739067 width=57) (actual time=0.077..2313.375 rows=120117 loops=1)

It's estimating >3M, but it finds 120K rows.

>                     Join Filter: (("inner".stock)::text = 
> ("outer".stock)::text)
>                     ->  Seq Scan on history  (cost=0.00..131.01 
> rows=5801 width=34) (actual time=0.016..34.845 rows=5801 loops=1)
>                     ->  Index Scan using idx_history_day on history 
> past_month  (cost=0.00..22.32 rows=645 width=23) (actual 
> time=0.020..0.185 rows=21 loops=5801)
>                           Index Cond: ((past_month."day" >= 
> ("outer"."day" - 30)) AND (past_month."day" < "outer"."day"))
>               ->  Hash  (cost=131.01..131.01 rows=5801 width=23) (actual 
> time=52.608..52.608 rows=5801 loops=1)
>                     ->  Seq Scan on history past_week (cost=0.00..131.01 
> rows=5801 width=23) (actual time=0.010..25.110 rows=5801 loops=1)
> 
> Total runtime: 13187.729 ms

Try running a vacuum analyze on the database (or at least the tables 
which differ in rows estimated and actual (history for example))

-- 
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
---------------------------------------------------------
Martín Marqués          |   Programador, DBA
Centro de Telemática	|     Administrador
                Universidad Nacional
                     del Litoral
---------------------------------------------------------



view thread (6+ messages)

Message-ID: <45FF07F5.4020204@bugs.unl.edu.ar>
Permalink:  ../45FF07F5.4020204@bugs.unl.edu.ar/
Also on:    postgresql.org/message-id/45FF07F5.4020204@bugs.unl.edu.ar

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: martin@bugs.unl.edu.ar, mailreg@numerixtechnology.de
  Subject: Re: triple self-join crawling
  In-Reply-To: <45FF07F5.4020204@bugs.unl.edu.ar>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox