Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 241849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:47:17+00:00 2026-05-11T20:47:17+00:00

I find it cumbersome to create a trigger just to get the current total

  • 0

I find it cumbersome to create a trigger just to get the current total rows of the table without doing COUNT(*) FROM table. I’m thinking if their planned index-organized tables for Postgres 8.5 could make it possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:47:17+00:00Added an answer on May 11, 2026 at 8:47 pm

    I wouldn’t have thought an index-organised table would necessarily be faster to scan to count all the visible tuples. Logically, it would have to go through the same amount of data, whether it’s organised so that data is in b-tree leaf nodes or in the existing heap format.

    Currently, postgresql indices only store [key,ctid] pairs (essentially). (A ctid is essentially a “rowid” – heap page number and tuple line pointer index) So you can’t count the rows in the table just by going through the index, because you need to check [xmin,xmax] for each tuple– and that’s only kept with the data, in the heap.

    You could put [xmin,xmax] in the index as well– suggestions for this crop up from time to time. But this bloats the indices, and to be useful all updates/deletes would have to make sure they were kept up-to-date: and that causes problems, not least because the work involved in doing an update has now expanded by some amount multiplied by the number of indices on the table. In the case of heavy indices such as on tsvector, or ones based on costly user expressions, this could take a while, and in some nasty cases not work at all, with rows now appearing to be live in the index, but dead in the heap. And the whole point of this exercise was supposed to be to allow the database to rely on the live-ness information in the index exclusively if possible. This cost would be incurred even if you were updating a non-indexed column– something the team went to some effort to speed up in 8.3 (heap-only tuples).

    I suppose one possibility would be to mark indices as optionally having [xmin,xmax] – e.g. only mark the pkey index that way. Then there would have to be planner changes to figure out when this was an advantage— it seems like quite a bit of work.

    Index-organised tables, if they work as I believe they do in Oracle (and SQL Server, where any table with a clustered index is basically index-organised) work by storing [key,tuple] in the primary key index instead (and presumably [key,pkey] in all the others) – no ctid, no heap. So “tuple” will contain [xmin,xmax,cminmax,natts,….] etc and you could satisfy the “select count(*) from table” just by scanning the index. But this essentially just the same as scanning the tuples on the heap— they don’t magically take up less space because they’re now in an “index”.

    AFAICT the main reason for an index-organised table is that a small table with a single primary-key index will take up 1 page instead of 3, and index scans by primary key may be a bit faster. I do seem to remember the Oracle-related advice I was given for IOTs was that they were intended for static dimension tables, and not general purpose use, partly due to the cost imposed on maintaining secondary indices (I don’t think Oracle stores [key,pkey] in IOT secondary indices, but rather some sort of alternative rowid).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 140k
  • Answers 140k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer YES and NO are predefined constants in Objective-C, declared in… May 12, 2026 at 7:50 am
  • Editorial Team
    Editorial Team added an answer protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) {… May 12, 2026 at 7:50 am
  • Editorial Team
    Editorial Team added an answer The code you posted does nothing really. You either have… May 12, 2026 at 7:50 am

Related Questions

I find myself often needing to use Integer.TryParse to test if a value is
I have a Windows service that runs implementations of a framework across multiple threads.
Coming from this question , I have a wxComboCtrl with a custom popup made
I created a custom autocomplete control, when the user press a key it queries

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.