Re: Showing applied extended statistics in explain Part 2 - Mailing list pgsql-hackers

From Ilia Evdokimov
Subject Re: Showing applied extended statistics in explain Part 2
Date
Msg-id d5222805-204a-4680-a157-00d3e8de6703@tantorlabs.com
Whole thread Raw
In response to Showing applied extended statistics in explain Part 2  (Tatsuro Yamada <tatsuro.yamada@ntt.com>)
Responses Re: Showing applied extended statistics in explain Part 2
List pgsql-hackers
Hi everyone!

Thank you for your work.

1) While exploring extended statistics, I encountered a bug that occurs 
when using EXPLAIN (STATS) with queries containing OR conditions:

CREATE TABLE t (a int, b int, c int, d int);
INSERT INTO t SELECT x/10+1, x, x + 10, x * 2 FROM 
generate_series(1,10000) g(x);
CREATE STATISTICS ON a, b FROM t;
CREATE STATISTICS ON c, d FROM t;
ANALYZE;

The following query works as expected:

EXPLAIN (STATS) SELECT * FROM t WHERE a > 0 AND b > 0 AND c > 0 AND d > 0;
                            QUERY PLAN
----------------------------------------------------------------
  Seq Scan on t  (cost=0.00..255.00 rows=10000 width=16)
    Filter: ((a > 0) AND (b > 0) AND (c > 0) AND (d > 0))
    Ext Stats: public.t_a_b_stat  Clauses: ((a > 0) AND (b > 0))
    Ext Stats: public.t_c_d_stat  Clauses: ((c > 0) AND (d > 0))
(4 rows)

However, when using OR conditions, the following query results in an error:

EXPLAIN (ANALYZE, STATS) SELECT * FROM t WHERE a > 0 AND b > 0 OR c > 0 
AND d > 0;
ERROR:  unrecognized node type: 314

2) It would be great if the STATS flag appeared as an option when 
pressing Tab during query input in the psql command-line interface.

Best regards,
Ilia Evdokimov,
Tantor Labs LLC.




pgsql-hackers by date:

Previous
From: Jakub Wartak
Date:
Subject: Re: AIO v2.0
Next
From: vignesh C
Date:
Subject: Re: Disallow UPDATE/DELETE on table with unpublished generated column as REPLICA IDENTITY