TGViewer
Engineering Notes Engineering Notes @boboshersnotes · 2.61K subscribers
Post #268 1.01K

Forwarded from Engineering Notes

#javob

It includes non-index column values to the actual index (b-tree).

Let's say you have a table named "users" with id, name and a bunch of other columns.
If you include name column in the index on id field:
CREATE INDEX
idx_user_id_include_name
ON users(id)
INCLUDE name;

Each time you query that uses this index and only asks for the columns on the index:
SELECT id, name 
FROM users
WHERE id = 1;
PostgreSQL doesn't necessarily go to the actual table after finding the required row, since it can find both id and name field on the index. This is called index-only scan.

If you query some other columns (let's say age), PostgreSQL first finds the required row id from the index and go to that row on the table to get age value, since it's not presented on the index. Searching on the index and fetching from the actual table. This is called index scan.
  • 👍 13
More from @boboshersnotes
  1. Oct 7, 2026– How much customization do you need? – Yes
  2. Oct 5, 2026I pinch the airpods once, Youtube video on my laptop is paused. I pinch it again, the vide…
  3. Oct 5, 2026The smartest kids in Kazakhstan should not be doing AI or maxxing out Claude. AI products…
  4. Sep 28, 2026https://www.youtube.com/watch?v=9HIy5dJE-zQ
  5. Sep 22, 2026spa-net.com qiziq challange ekan, kun bo'yi "enter" bosishdan zerikkanda bosh qotirib ko'r…
  6. Sep 21, 2026Bizda odatda juma kunlarining ikkinchi yarmi ishga to'g'ridan-to'g'ri aloqador bo'lmagan n…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →