brin.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * AM-callable functions for BRIN indexes
  3. *
  4. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  5. * Portions Copyright (c) 1994, Regents of the University of California
  6. *
  7. * IDENTIFICATION
  8. * src/include/access/brin.h
  9. */
  10. #ifndef BRIN_H
  11. #define BRIN_H
  12. #include "nodes/execnodes.h"
  13. #include "utils/relcache.h"
  14. /*
  15. * Storage type for BRIN's reloptions
  16. */
  17. typedef struct BrinOptions
  18. {
  19. int32 vl_len_; /* varlena header (do not touch directly!) */
  20. BlockNumber pagesPerRange;
  21. bool autosummarize;
  22. } BrinOptions;
  23. /*
  24. * BrinStatsData represents stats data for planner use
  25. */
  26. typedef struct BrinStatsData
  27. {
  28. BlockNumber pagesPerRange;
  29. BlockNumber revmapNumPages;
  30. } BrinStatsData;
  31. #define BRIN_DEFAULT_PAGES_PER_RANGE 128
  32. #define BrinGetPagesPerRange(relation) \
  33. (AssertMacro(relation->rd_rel->relkind == RELKIND_INDEX && \
  34. relation->rd_rel->relam == BRIN_AM_OID), \
  35. (relation)->rd_options ? \
  36. ((BrinOptions *) (relation)->rd_options)->pagesPerRange : \
  37. BRIN_DEFAULT_PAGES_PER_RANGE)
  38. #define BrinGetAutoSummarize(relation) \
  39. (AssertMacro(relation->rd_rel->relkind == RELKIND_INDEX && \
  40. relation->rd_rel->relam == BRIN_AM_OID), \
  41. (relation)->rd_options ? \
  42. ((BrinOptions *) (relation)->rd_options)->autosummarize : \
  43. false)
  44. extern void brinGetStats(Relation index, BrinStatsData *stats);
  45. #endif /* BRIN_H */