DEV Community

Maruf13
Maruf13

Posted on

1

Methods of reading database Tables

In this post, Two typical access methods, sequential scan and B-tree index scan, are outlined here:

✔️ Sequential scan:

All tuples in all pages are sequentially read by scanning all line pointers in each page. show below-

Sequential Scan

✔️ B-tree index scan:

An index file contains index tuples, each of which is composed of an index key and a TID pointing to the target heap tuple.

If the index tuple with the key that you are looking for has been found, PostgreSQL reads the desired heap tuple using the obtained TID value.

For example, In below image , TID value of the obtained index tuple is ‘(block = 7, Offset = 2)’. It means that the target heap tuple is 2nd tuple in the 7th page within the table, so PostgreSQL can read the desired heap tuple without unnecessary scanning in the pages.

B-tree index scan

✔️ References:

  1. https://age.apache.org/
  2. https://github.com/apache/age
  3. https://www.interdb.jp/pg/index.html

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay