apache / apache/cloudberry

Replace the hacky way stats pg_appendonly.segfilecount

Offen
#97 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
type: Enhancement
Vorherrschende Sprache
C
Sterne
1.4k
Forks
247
Ø Merge
4 T. 3 Std.
Gemergte PRs (30 T.)
39

Beschreibung

### Cloudberry Database version

_No response_

### What happened

This is added by me when implementing AO/AOCS's parallel scan feature.

`segfilecount` is used to parallel workers for AO/AOCS.
It's updated by VACCUM, ANALYZE, TRUNCATE command and auto vacuum process.
I use VPgClassStats.relallvisible to represent segment file count of AO/AOCS as we are hurry for that feature, and I could
save a MessageType of libpq and etc.

It works well because AO/AOCS does not currently have an equivalent to Heap's 'all visible pages',
relallvisible is always set to 0 in pg_class for AO/AOCS tabes. But QE use this field in libpq to represent AO/AOCS's total file segment number when vacuum ao tables.
See more comments in below files.

```c
typedef struct VPgClassStats
{
Oid relid;
BlockNumber rel_pages;
double rel_tuples;
BlockNumber relallvisible;
} VPgClassStats;
```
The approach is very hacky and not good.
We should reconsider the implementation for this including VACUUM, ANALYZE, TRUNCATE and auto vacuum process.

vacuum_ao.c
```c
/* AO/AOCO does not currently have an equivalent to
Heap's 'all visible pages', use this field to represent
AO/AOCO's total segment file count */
```
vacuum.h
```c
* relallvisible
* AO/AOCO does not currently have an equivalent to Heap's 'all visible pages',
* relallvisible is always set to 0 in pg_class for AO/AOCO tabes. But QE use
* this field in libpq to represent AO/AOCO's total file segment number when
* vacuum ao tables.
* Remember to reset relallvisible to 0 after qd get file segment number and
* before updating pg_class.
* See vac_update_relstats_from_list in vacuum.c and
* vac_update_relstats in vacuum_ao.c
```

### What you think should happen instead

_No response_

### How to reproduce

No need.

### Operating System

Ubuntu.

### Anything else

_No response_

### Are you willing to submit PR?

- [ ] Yes, I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://cloudberrydb.org/community/coc).

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, die Kommentare und die Handhabung von relallvisible in vacuum_ao.c und vacuum.h zu lesen; verfolge dann, wie VACUUM, ANALYZE, TRUNCATE und autovacuum den Wert aktualisieren und wie QE ihn über libpq verarbeitet. Die Aufgabe ist abgeschlossen, wenn die Anzahl der Segmentdateien relallvisible nicht mehr verwendet und die betroffenen Wartungspfade und der Consumer sich auf eine dedizierte Repräsentation einigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
c, postgresql
Bereich
databases
Issue-Typ
Refactoring
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.