Subject: Re: Where is the filter?

From: Robert Haas <[email-masked]>
Date: Mon, 6 Feb 2023 11:15:42 -0500

On Sat, Feb 4, 2023 at 11:29 PM [email-masked] <[email-masked]> wrote:
> When I use 'select * from t where a = 1'; And I debug to find where the 'a = 1' is used,
> when I arrive ExecScan in src/backend/executor/execScan.c, line 158, where this 'a = 1' is
> stored in?

It depends somewhat on what query plan you got. For instance if it was
a Seq Scan then it will be a filter-condition, or "qual", and the call
to ExecQual() later in ExecScan() will be responsible for evaluating
it. But if you are using an index scan, then it will probably become
an index qual, and those are passed down into the index machinery and
internally handled by the index AM. It's a good idea when you're
debugging this sort of thing to start by looking at the EXPLAIN or
EXPLAIN ANALYZE output, and perhaps also the output with
debug_print_plan = true.

-- 
Robert Haas
EDB: http://www.enterprisedb.com