Re: Showing applied extended statistics in explain Part 2

From: Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>
To: Tatsuro Yamada <yamatattsu(at)gmail(dot)com>, Masahiro(dot)Ikeda(at)nttdata(dot)com
Cc: tomas(dot)vondra(at)enterprisedb(dot)com, tatsuro(dot)yamada(at)ntt(dot)com, pgsql-hackers(at)postgresql(dot)org, Masao(dot)Fujii(at)nttdata(dot)com
Subject: Re: Showing applied extended statistics in explain Part 2
Date: 2024-11-18 12:52:42
Message-ID: d5222805-204a-4680-a157-00d3e8de6703@tantorlabs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Maxim Orlov 2024-11-18 13:22:38 Re: POC: make mxidoff 64 bits
Previous Message jian he 2024-11-18 12:42:56 Re: NOT ENFORCED constraint feature