[PostgreSQL tutorial] large object in PostgreSQL

Source: Internet
Author: User

  1. // There are mainly the following two system tables. pg_largeobject_metadata records the permissions mainly. Only pg_largeobject is useful.
  2. CATALOG (FIG, 2995)
  3. {
  4. Oid lomowner;/* OID of the largeobject owner */
  5. # Ifdef CATALOG_VARLEN/* variable-length fields start here */
  6. Aclitem lomacl [1];/* Access permissions */
  7. # Endif
  8. } FormData_pg_largeobject_metadata;
  9. /* 
  10. * Each "page" (tuple) of a large object can hold this much data 
  11. * We cocould set this as high as BLCKSZ less some overhead, but it seems 
  12. * Better to make it a smaller value, so that not as much space is used 
  13. * Up when a page-tuple is updated. Note that the value is deliberately 
  14. * Chosen large enough to trigger the tuple toaster, so that we will 
  15. * Attempt to compress page tuples in-line. (But they won't be moved off 
  16. * Unless the user creates a toast-table for pg_largeobject ...) 
  17. * Also, it seems to be a smart move to make the page size be a power of 2, 
  18. * Since clients will often be written to send data in power-of-2 blocks. 
  19. * This avoids unnecessary tuple updates caused by partial-page writes. 
  20. */
  21. # Define LOBLKSIZE (BLCKSZ/4)
  22. CATALOG (pg_largeobject, 2613) BKI_WITHOUT_OIDS
  23. {
  24. Oid loid;/* Identifier of large object */
  25. Int4 pageno;/* Page number (starting from 0 )*/
  26. /* Data has variable length, but we allow direct access; see inv_api.c */
  27. Bytea data;/* Data for page (may be zero-length )*/
  28. } FormData_pg_largeobject;

All the large objects are split into LOBLKSIZE values and placed into pg_largeobject. They are differentiated by loid. Each part of a large object is divided by pageno (the sequence number of the tuples is more reasonable ), in order,

Pageno is calculated based on the data offset/LOBLKSIZE to be written.

Pg's large object implementation is relatively simple and is not suitable for the use of large data volumes and will become a bottleneck of the system.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.