Re: Unify drop-by-OID functions

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unify drop-by-OID functions
Date: 2020-05-05 17:21:36
Message-ID: CAEudQAoDdd+T0H9bfk6JCiDZFk+KPVN=bZ4ZuC9Nx=9=whZb8A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em ter., 5 de mai. de 2020 às 13:06, Robert Haas <robertmhaas(at)gmail(dot)com>
escreveu:

> On Fri, May 1, 2020 at 5:32 PM Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> wrote:
> > I can suggest improvements?
> >
> > 1. In case Object is cached, delay open_table until the last moment, for
> the row to be blocked as little as possible and close the table as quickly
> as possible.
> > 2. In case Object is cached and the tuple is invalid, do not open table.
> > 3. Otherwise, is it possible to call systable_endscan, after table_close?
> >
> > I think that lock resources, for as little time as possible, it is an
> advantage..
>
> Only if it's correct, which (3) definitely wouldn't be, and I'm
> doubtful about (1) as well.
>
Ok, so the question. If (3) is not safe, obvious we shouldn't use, and must
call table_close, after systable_endscan.
Now (1) and (2), I would have no hesitation in using it.
I work with ERP, and throughout the time, the later, lock resources and
release them soon, the better, for the performance of the system as a whole.
Even if it doesn't make much difference locally, using this process,
throughout the system, efficiency is noticeable.
Apparently, it is more code, but it is less resources used and for less
time.
And (2), if it is a case, frequently, no table would be blocked in this
function.

Simple examples.

Exemple 1:
FILE * f;
f = fopen("data.txt", "r");
if (f != NULL) {
char buf[512];
size_t result;
result = fread(&buf, sizeof(char), 512, f);
fclose(f); // we no longer need the resource, release.
if (result != 0) {
process(buf);
printf("buf=%s\n", buf);
}
}

Exemple 2:
FILE * f;
f = fopen("data.txt", "r");
if (f != NULL) {
char buf[512];
size_t result;
result = fread(&buf, sizeof(char), 512, f);
if (result != 0) {
process(buf);
printf("buf=%s\n", buf);
}
fclose(f); // resource blocked until the end.
}

regards,
Ranier Vilela

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2020-05-05 17:28:58 Re: Unify drop-by-OID functions
Previous Message Bruce Momjian 2020-05-05 17:18:09 Re: PG 13 release notes, first draft