pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: New design for FK-based join selectivity estimation
Date: Mon, 20 Jun 2016 12:39:11 -0400
Message-ID: <28279.1466440751@sss.pgh.pa.us> (raw)
In-Reply-To: <0cc0ee1c-7c47-7971-767a-0cf22b7f0a93@2ndquadrant.com>
References: <31041.1465069446@sss.pgh.pa.us>
	<25469.1465138626@sss.pgh.pa.us>
	<b790983b-4503-66ff-30c0-e7f46e3ad2f7@2ndquadrant.com>
	<15245.1466031608@sss.pgh.pa.us>
	<b1648fc3-3fd9-312e-f02c-f7fc6278d7d3@2ndquadrant.com>
	<20877.1466175216@sss.pgh.pa.us>
	<ee1a76b0-43ed-a6a4-2acb-7c410d0be3ac@2ndquadrant.com>
	<15396.1466268742@sss.pgh.pa.us>
	<13294.1466278050@sss.pgh.pa.us>
	<0cc0ee1c-7c47-7971-767a-0cf22b7f0a93@2ndquadrant.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Tomas Vondra <tomas.vondra@2ndquadrant.com> writes:
> OK, thanks. The one thing we haven't done is testing the performance, to 
> see how this fares. So I've repeated the tests I've done on the original 
> version of the patch here

Hmm.  I'm not that excited about these results, for a couple of reasons:

* AFAICS, all the numbers are collected from the first execution of a
query within a session, meaning caches aren't populated and everything
has to be loaded from disk (or at least shared buffers).

* I do not credit hundreds of completely redundant FKs between the same
two tables as being representative of plausible real-world cases.

I modified your new script as attached to get rid of the first problem.
Comparing HEAD with HEAD minus commit 100340e2d, in non-assert builds,
I get results like this for the 100-foreign-key case (with repeat
count 1000 for the data collection script):

select code, test, avg(time),stddev(time) from data group by 1,2 order by 1,2;
  code  | test  |        avg         |       stddev        
--------+-------+--------------------+---------------------
 head   | t1/t2 |  0.065045045045045 | 0.00312962651081508
 head   | t3/t4 |  0.168561561561562 | 0.00379087132124092
 head   | t5/t6 |  0.127671671671672 | 0.00326275949269809
 head   | t7/t8 |  0.391057057057056 | 0.00590249325300915
 revert | t1/t2 | 0.0613933933933937 |  0.0032082678131875
 revert | t3/t4 | 0.0737507507507501 | 0.00221692725859567
 revert | t5/t6 |  0.123759759759759 | 0.00431225386651805
 revert | t7/t8 |  0.154082082082081 | 0.00405118420422266
(8 rows)

So for the somewhat-credible cases, ie 100 unrelated foreign keys,
I get about 3% - 6% slowdown.  The 100-duplicate-foreign-keys case
does indeed look like about a 2X slowdown, but as I said, I do not
think that has anything to do with interesting usage.

In any case, the situation I was worried about making better was
queries joining many tables, which none of this exercises at all.

			regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

fk-perf-run-2.sh (text/plain, 694B) download DB=$1 COUNT=$2 for i in `seq 1 $COUNT`; do echo "EXPLAIN ANALYZE SELECT * FROM t1 JOIN t2 USING (a);" done | psql $DB | grep 'Planning' | tail -n +2 | awk '{print "t1/t2\t"$3}' for i in `seq 1 $COUNT`; do echo "EXPLAIN ANALYZE SELECT * FROM t3 JOIN t4 USING (a);" done | psql $DB | grep 'Planning' | tail -n +2 | awk '{print "t3/t4\t"$3}' for i in `seq 1 $COUNT`; do echo "EXPLAIN ANALYZE SELECT * FROM t5 JOIN t6 USING (a,b,c,d);" done | psql $DB | grep 'Planning' | tail -n +2 | awk '{print "t5/t6\t"$3}' for i in `seq 1 $COUNT`; do echo "EXPLAIN ANALYZE SELECT * FROM t7 JOIN t8 USING (a,b,c,d);" done | psql $DB | grep 'Planning' | tail -n +2 | awk '{print "t7/t8\t"$3}'

view thread (25+ messages)  latest in thread

Message-ID: <28279.1466440751@sss.pgh.pa.us>
Permalink:  ../28279.1466440751@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28279.1466440751@sss.pgh.pa.us

 · 

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-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, tomas.vondra@2ndquadrant.com
  Subject: Re: New design for FK-based join selectivity estimation
  In-Reply-To: <28279.1466440751@sss.pgh.pa.us>
  References: <31041.1465069446@sss.pgh.pa.us> <25469.1465138626@sss.pgh.pa.us> <b790983b-4503-66ff-30c0-e7f46e3ad2f7@2ndquadrant.com> <15245.1466031608@sss.pgh.pa.us> <b1648fc3-3fd9-312e-f02c-f7fc6278d7d3@2ndquadrant.com> <20877.1466175216@sss.pgh.pa.us> <ee1a76b0-43ed-a6a4-2acb-7c410d0be3ac@2ndquadrant.com> <15396.1466268742@sss.pgh.pa.us> <13294.1466278050@sss.pgh.pa.us> <0cc0ee1c-7c47-7971-767a-0cf22b7f0a93@2ndquadrant.com> <28279.1466440751@sss.pgh.pa.us>

* 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