Thread: Regarding ambulkdelete, amvacuumcleanup index methods

Regarding ambulkdelete, amvacuumcleanup index methods

From
Abinaya k
Date:
Hai all,
      We are building In-memory index extension for postgres. We would capture table inserts, updates, deletes using triggers. During vacuum operation, postgres would give calls to ambulkdelete, amvacuumcleanup (as part of index cleanup). As we handle all updates, deletes using triggers, we don't have to do any index cleanup in ambulkdelete. But, what stats should i return from ambulkdelete and amvacuumcleanup? Is that necessary to return stats from ambulkdelete and amvacuumcleanup ?

Re: Regarding ambulkdelete, amvacuumcleanup index methods

From
Masahiko Sawada
Date:
On Wed, Jan 24, 2018 at 1:27 PM, Abinaya k <abinaya.k.496@gmail.com> wrote:
> Hai all,
>       We are building In-memory index extension for postgres. We would
> capture table inserts, updates, deletes using triggers. During vacuum
> operation, postgres would give calls to ambulkdelete, amvacuumcleanup (as
> part of index cleanup). As we handle all updates, deletes using triggers, we
> don't have to do any index cleanup in ambulkdelete. But, what stats should i
> return from ambulkdelete and amvacuumcleanup? Is that necessary to return
> stats from ambulkdelete and amvacuumcleanup ?

Both ambulkdelete and amvacuumcleanup return an IndexBulkDeleteResult.
If you return a non-NULL value, the values of returned
IndexBulkDeleteResult are used for updating the index statistics and
reporting the statistics of bulk deletion in lazy_cleanup_index. For
example, num_pages and num_index_tuples are used for updating
pg_class.relpages and pg_class.reltuples. But if you return NULL from
them, these are skipped.

Regards,

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


Re: Regarding ambulkdelete, amvacuumcleanup index methods

From
Abinaya k
Date:
Thanks for your response.

Hope those stats will be used by Query Planner.

So, just for my understanding, if i don't return stats (returning NULL from index_bulk_delete and index_vacuum_cleanup functions), Query Planner will not consider my Index as part of Query Path, beyond that i don't expect any bad consequences.

Please clarify me, if i'm wrong.

Regards,
Abinaya K



On Wed, Jan 24, 2018 at 1:24 PM, Masahiko Sawada <sawada.mshk@gmail.com> wrote:
On Wed, Jan 24, 2018 at 1:27 PM, Abinaya k <abinaya.k.496@gmail.com> wrote:
> Hai all,
>       We are building In-memory index extension for postgres. We would
> capture table inserts, updates, deletes using triggers. During vacuum
> operation, postgres would give calls to ambulkdelete, amvacuumcleanup (as
> part of index cleanup). As we handle all updates, deletes using triggers, we
> don't have to do any index cleanup in ambulkdelete. But, what stats should i
> return from ambulkdelete and amvacuumcleanup? Is that necessary to return
> stats from ambulkdelete and amvacuumcleanup ?

Both ambulkdelete and amvacuumcleanup return an IndexBulkDeleteResult.
If you return a non-NULL value, the values of returned
IndexBulkDeleteResult are used for updating the index statistics and
reporting the statistics of bulk deletion in lazy_cleanup_index. For
example, num_pages and num_index_tuples are used for updating
pg_class.relpages and pg_class.reltuples. But if you return NULL from
them, these are skipped.

Regards,

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


Re: Regarding ambulkdelete, amvacuumcleanup index methods

From
Masahiko Sawada
Date:
On Thu, Jan 25, 2018 at 5:53 PM, Abinaya k <abinaya.k.496@gmail.com> wrote:
> Thanks for your response.
>
> Hope those stats will be used by Query Planner.
>
> So, just for my understanding, if i don't return stats (returning NULL from
> index_bulk_delete and index_vacuum_cleanup functions), Query Planner will
> not consider my Index as part of Query Path, beyond that i don't expect any
> bad consequences.

IIUC, the query planner doesn't ignore such indexes even if these values are 0.

Regards,

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