Re: a wrong index choose when statistics is out of date

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Andy Fan <zhihuifan1213(at)163(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: a wrong index choose when statistics is out of date
Date: 2024-03-07 10:06:22
Message-ID: CAApHDvo5S5xqWQR1HKzx=5UpBr1ZKhwEtxEkt=3q0z4oR+TnPA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 6 Mar 2024 at 02:09, Andy Fan <zhihuifan1213(at)163(dot)com> wrote:
> This patch introduces a new attoptions like this:
>
> ALTER TABLE t ALTER COLUMN col set (force_generic=true);
>
> Then selfunc.c realizes this and ignore the special Const value, then
> average selectivity is chosen. This fall into the weakness of generic
> plan, but this patch doesn't introduce any new weakness and we leave the
> decision to user which could resolve some problem. Also this logic only
> apply to eqsel since the ineqsel have the get_actual_variable_range
> mechanism which is helpful for index choose case at least.

If you don't want the planner to use the statistics for the column why
not just do the following?

ALTER TABLE t ALTER COLUMN col SET STATISTICS 0;

ANALYZE won't delete any existing statistics, so that might need to be
done manually.

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2024-03-07 10:11:32 Re: [EXTERNAL] Re: Add non-blocking version of PQcancel
Previous Message Hannu Krosing 2024-03-07 09:54:50 Re: Function and Procedure with same signature?