SeqScan costs

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: SeqScan costs
Date: 2008-08-12 18:31:06
Message-ID: 1218565866.5343.118.camel@ebony.2ndQuadrant
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


If we access a 1 block table using a SeqScan then it costs
seq_page_cost, or 1 by default.

If we access the same 1 block table using an IndexScan then the access
costs random_page_cost to access the index block and then
random_page_cost to access to the data block.

So the same block accessed for different reasons is judged to have two
different costs. But that clearly must be wrong, since the I/O is a 1
block I/O in either case,

This leads to favouring seq scans in cases where the actual index scan
timing is actually less than seq scan.

Proposal: Make the first block of a seq scan cost random_page_cost, then
after that every additional block costs seq_page_cost.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Euler Taveira de Oliveira 2008-08-12 19:25:14 Re: temporary statistics option at initdb time
Previous Message Markus Wanner 2008-08-12 18:24:31 Re: Plugin system like Firefox