pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: kpi6288@gmail.com
To: pgsql-general@postgresql.org
Subject: AW: AW: CTE with JOIN of two tables is much faster than a regular query
Date: Sat, 18 Aug 2018 16:32:34 +0200
Message-ID: <005701d43700$4dd920b0$e98b6210$@gmail.com> (raw)
In-Reply-To: <ad749c34-469c-5838-ec75-bc7232afba47@aklaver.com>
References: <004b01d436d6$ff96c840$fec458c0$@gmail.com>
	<42ce9b74-0671-ecba-3deb-dc8bc8d5e9b3@a-kretschmer.de>
	<005301d436e3$cb120960$61361c20$@gmail.com>
	<ad749c34-469c-5838-ec75-bc7232afba47@aklaver.com>

> -----Ursprüngliche Nachricht-----
> Von: Adrian Klaver <adrian.klaver@aklaver.com>
> Gesendet: Samstag, 18. August 2018 16:24
> 
> To try to replicate what the CTE is doing I would try:
> SELECT  *
> FROM	Doc
> JOIN  (SELECT	uDocRef, F.oID, Doc.szText
> FROM F JOIN	Doc ON	F.uDocRef = Doc.udocid) AS D
> ON D.uDocRef = Doc.udocid
> WHERE D.szText ILIKE '%480GB%'

No difference - still starting with the full scan on Doc and lasting 67 seconds: 

"Nested Loop  (cost=8006.98..8700.40 rows=5 width=750) (actual time=66845.857..66852.705 rows=10 loops=1)"
"  ->  Hash Join  (cost=8006.56..8694.93 rows=5 width=391) (actual time=66845.838..66852.613 rows=10 loops=1)"
"        Hash Cond: (f.udocref = doc_1.udocid)"
"        ->  Seq Scan on f  (cost=0.00..566.05 rows=32605 width=32) (actual time=0.002..3.428 rows=32605 loops=1)"
"        ->  Hash  (cost=8006.32..8006.32 rows=19 width=359) (actual time=66845.431..66845.431 rows=16 loops=1)"
"              Buckets: 1024  Batches: 1  Memory Usage: 19kB"
"              ->  Seq Scan on doc doc_1  (cost=0.00..8006.32 rows=19 width=359) (actual time=9042.984..66845.398 rows=16 loops=1)"
"                    Filter: (sztext ~~* '%480GB%'::text)"
"                    Rows Removed by Filter: 125930"
"  ->  Index Scan using doc_udocid_key on doc  (cost=0.42..1.08 rows=1 width=375) (actual time=0.008..0.008 rows=1 loops=10)"
"        Index Cond: (udocid = f.udocref)"
"Planning time: 252.162 ms"
"Execution time: 66852.737 ms"






view thread (2+ messages)  latest in thread

Message-ID: <005701d43700$4dd920b0$e98b6210$@gmail.com>
Permalink:  ../005701d43700$4dd920b0$e98b6210$@gmail.com/
Also on:    postgresql.org/message-id/005701d43700$4dd920b0$e98b6210$@gmail.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: kpi6288@gmail.com
  Subject: Re: CTE with JOIN of two tables is much faster than a regular query
  In-Reply-To: <005701d43700$4dd920b0$e98b6210$@gmail.com>
  References: <004b01d436d6$ff96c840$fec458c0$@gmail.com> <42ce9b74-0671-ecba-3deb-dc8bc8d5e9b3@a-kretschmer.de> <005301d436e3$cb120960$61361c20$@gmail.com> <ad749c34-469c-5838-ec75-bc7232afba47@aklaver.com> <005701d43700$4dd920b0$e98b6210$@gmail.com>

* 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