Re: Unused variable scanned_tuples in LVRelStats

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unused variable scanned_tuples in LVRelStats
Date: 2017-08-03 05:10:26
Message-ID: CAD21AoAwKgVU=QRHJQjtGuqe_B1eT_V64QQMO0yrxv+Tp53ndg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 2, 2017 at 11:40 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Tue, Jul 4, 2017 at 10:13 PM, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>> scanned_tuples variable in LVRelStats is introduced by commit b4b6923e
>> but it seems to me that it's actually not used. We store num_tuples
>> into vacrelstats->scanned_tuples after scanned all blocks, and the
>> comment mentioned that saving it in order to use later but we actually
>> use num_tuples instead of vacrelstats->scanned_tuples from there. I
>> think the since the name of scanned_tuples implies more clearer
>> purpose than num_tuples it's better to use it instead of num_tuples,
>> or we can remove scanned_tuples from LVRelStats.

Thank you for the comment!

>
> I think we should only store stuff in LVRelStats if it needs to be
> passed to some other function.

Agreed. From this point of view, num_tuples is only one variable of
LVRelStats that is not passed to other functions.

> Data that's only used in
> lazy_scan_heap() can just be kept in local variables. We could rename
> the local variable, though, since I agree with you that scanned_tuples
> is clearer.
>

So we can remove scanned_tuples from LVRelStats struct and change the
variable name num_tuples to scanned_tuples. Attached updated patch.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachment Content-Type Size
fix_vacuumlazy_v2.patch application/octet-stream 2.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2017-08-03 05:30:06 Re: map_partition_varattnos() and whole-row vars
Previous Message Amit Langote 2017-08-03 05:04:49 Re: A bug in mapping attributes in ATExecAttachPartition()