apache / apache/cloudberry

Replace the hacky way stats pg_appendonly.segfilecount

Aperta
#97 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
type: Enhancement
Lingua principale
C
Stelle
1.4k
Fork
247
Merge medio
4g 3h
PR unite (30g)
39

Descrizione

### 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).

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia leggendo i commenti e la gestione di relallvisible in vacuum_ao.c e vacuum.h; quindi traccia il modo in cui VACUUM, ANALYZE, TRUNCATE e autovacuum aggiornano il valore e il modo in cui QE lo consuma tramite libpq. Il lavoro è completo quando il conteggio dei file di segmento non usa più relallvisible e i percorsi di manutenzione interessati e il consumer concordano su una rappresentazione dedicata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
c, postgresql
Ambito
databases
Tipo di issue
Refactoring
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.