Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why is cpu_index_tuple_cost different from cpu_tuple_cost in Postgresql

What is the reason of the values of cpu_index_tuple_cost and cpu_tuple_cost being different?
Shouldn’t it take the same amount of time, once the reader head is already reading that page?

I checked the documentation (https://www.postgresql.org/docs/current/runtime-config-query.html#GUC-CPU-TUPLE-COST) and I expected cpu_index_tuple_cost and cpu_tuple_cost to be same.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

“Reader head” and “page” seem to suggest that disk I/O plays a role here, but the cost parameters for that are random_page_cost and seq_page_cost. cpu_index_tuple_cost and cpu_tuple_cost are about the CPU time spent processing a single index or table entry. Now index tuples are typically much smaller than table tuples, so estimating a lower cost is justified.

I dug into the history of that parameter, and it was introduced in commit b1577a7c78 in 2000 with a value of 0.001, a tenth of cpu_tuple_cost. Later, it was decided that the value was too small (see the discussion), and commit e4de635a2b from 2006 changed the default value to 0.005.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading