Re: Probleme mit sehr langsamen Left Outer Join

From: "Robert J(dot) Rotter" <rotter(at)denic(dot)de>
To: pgsql-de-allgemein(at)postgresql(dot)org
Subject: Re: Probleme mit sehr langsamen Left Outer Join
Date: 2016-03-02 07:19:26
Message-ID: OF300517B6.63DB2118-ONC1257F6A.0026F2F5-C1257F6A.00283B5D@notes.denic.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-de-allgemein

Andreas Kretschmer <akretschmer(at)spamfence(dot)net> schrieb am 26.02.2016
21:36:58:

> Robert J. Rotter <rotter(at)denic(dot)de> wrote:
>
> > Hallo,
> >
> > ich benötige mal einen Tipp von der Postgres Community:
> >
> > Ich habe ein Query, das von einer Applikation abgesetzt wird was sehr,

> > sehr lange dauert.
> > Wohl mehrere Stunden, ich habe es nicht zu Ende laufen lassen.
> >
> > Die Query sieht wie folgt aus (Schema-, Tabellen- und Spaltennamen
habe
> > ich abgeändert):
> >
> > select <diverse spalten> from schema1.table1 cr
> > left outer join
> > schema1.view1 co on cr.c_id = co.cId
> > where name = 'name1';
> >
> > wobei der view1 die folgende Form besitzt:
> >
> > Folgender Query Plan kommt dabei raus:
>
> zeig mal explain analyse ...
>
>
> Andreas

Hi, sorry der EXPLAIN ANALYZE hat ein wenig länger gedauert. Gute 57
Stunden.

QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Hash Right Join (cost=43891.46..74562849.42 rows=1 width=302) (actual
time=57760187.680..207029422.793 rows=1 loops=1)
Hash Cond: (eci.cid = cr.cid)
-> Merge Join (cost=43883.15..28736387.35 rows=3332833000 width=157)
(actual time=153.804..206956782.687 rows=40063581 loops=1)
Merge Cond: (((c.cid)::text = (eci.cid)::text) AND (c.rid =
eci.rid))
-> Index Scan using pk_c on c2 c (cost=0.56..4542612.58
rows=39802190 width=132) (actual time=0.048..55931323.269 rows=40063581
loops=1)
-> Index Scan using pk_e1 on e1 eci (cost=0.56..2938434.16
rows=41891849 width=40) (actual time=0.031..16125164.797 rows=40063582
loops=1)
-> Hash (cost=8.30..8.30 rows=1 width=4) (actual time=26.795..26.795
rows=1 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 1kB
-> Index Only Scan using pk_table1 on table1 cr (cost=0.28..8.30
rows=1 width=4) (actual time=26.772..26.780 rows=1 loops=1)
Index Cond: (name = 'a_name'::text)
Heap Fetches: 1
Total runtime: 207029423.634 ms
(12 rows)

Ich hoffe das war es wert. ;)

Ich hab auch nochmal die Zeilen gezählt:

schema2.c2 --> 40066021 rows
schema1.e1 --> 40066169 rows
schema1.table1 --> 7408 rows

Viele Grüße

Robert J. Rotter

In response to

Responses

Browse pgsql-de-allgemein by date

  From Date Subject
Next Message Andreas Kretschmer 2016-03-02 07:55:20 Re: Probleme mit sehr langsamen Left Outer Join
Previous Message Thomas Markus 2016-03-02 07:10:53 Re: Probleme mit sehr langsamen Left Outer Join