【PostgreSQL使用教程】PostgreSQL 中的 large object

來源:互聯網
上載者:User

  1. //主要有下面兩個系統資料表,pg_largeobject_metadata主要記錄許可權的,有用的只有pg_largeobject   
  2.   
  3.   
  4.   
  5. CATALOG(pg_largeobject_metadata,2995)  
  6. {  
  7.     Oid         lomowner;       /* OID of the largeobject owner */  
  8. #ifdef CATALOG_VARLEN           /* variable-length fields start here */   
  9.     aclitem     lomacl[1];      /* access permissions */  
  10. #endif   
  11. } FormData_pg_largeobject_metadata;  
  12.   
  13. /* 
  14.  * Each "page" (tuple) of a large object can hold this much data 
  15.  * 
  16.  * We could set this as high as BLCKSZ less some overhead, but it seems 
  17.  * better to make it a smaller value, so that not as much space is used 
  18.  * up when a page-tuple is updated.  Note that the value is deliberately 
  19.  * chosen large enough to trigger the tuple toaster, so that we will 
  20.  * attempt to compress page tuples in-line.  (But they won't be moved off 
  21.  * unless the user creates a toast-table for pg_largeobject...) 
  22.  * 
  23.  * Also, it seems to be a smart move to make the page size be a power of 2, 
  24.  * since clients will often be written to send data in power-of-2 blocks. 
  25.  * This avoids unnecessary tuple updates caused by partial-page writes. 
  26.  */  
  27. #define LOBLKSIZE  (BLCKSZ / 4)   
  28.   
  29. CATALOG(pg_largeobject,2613) BKI_WITHOUT_OIDS  
  30. {  
  31.     Oid         loid;           /* Identifier of large object */  
  32.     int4        pageno;         /* Page number (starting from 0) */  
  33.     /* data has variable length, but we allow direct access; see inv_api.c */  
  34.     bytea       data;           /* Data for page (may be zero-length) */  
  35. } FormData_pg_largeobject;  

所有的大對象全部拆成 LOBLKSIZE  大小,放入 pg_largeobject 之中,通過 loid進行區分, 每個大對象拆分成的各個部分通過 pageno(叫元組序號更合理),進行順序的關聯起來,

pageno是通過 要寫入的資料offset / LOBLKSIZE  計算的

pg的大對象實現的比較簡單,並不適合大資料量的使用,會成為系統的瓶頸.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.