pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Anibal David Acosta <aa@devshock.com>
To: 'Craig James' <craig_james@emolecules.com>
To: pgsql-performance@postgresql.org
Subject: Re: how fast index works?
Date: Tue, 6 Sep 2011 16:28:12 -0400
Message-ID: <008b01cc6cd3$820581c0$86108540$@devshock.com> (raw)
In-Reply-To: <4E6671DE.40506@emolecules.com>
References: <001501cc6cc3$3649a3c0$a2dceb40$@devshock.com>
	<4E6671DE.40506@emolecules.com>

Thanks!

 

 

De: pgsql-performance-owner@postgresql.org
[mailto:pgsql-performance-owner@postgresql.org] En nombre de Craig James
Enviado el: martes, 06 de septiembre de 2011 03:18 p.m.
Para: pgsql-performance@postgresql.org
Asunto: Re: [PERFORM] how fast index works?

 

On 9/6/11 11:31 AM, Anibal David Acosta wrote: 

Hi everyone, 

 

My question is, if I have a table with 500,000 rows, and a SELECT of one row
is returned in 10 milliseconds, if the table has 6,000,000 of rows and
everything is OK (statistics, vacuum etc) 

can i suppose that elapsed time will be near to 10?


Theoretically the index is a B-tree with log(N) performance, so a larger
table could be slower.  But in a real database, the entire subtree might
fall together in one spot on the disk, so retrieving a record from a 500,000
record database could take the same time as a 6,000,000 record database.

On the other hand, if you do a lot of updates and don't have your autovacuum
parameters set right, a 500,000 record index might get quite bloated and
slow as it digs through several disk blocks to find one record.

There is no simple answer to your question.  In a well-maintained database,
6,000,000 records are not a problem.

Craig

view thread (7+ messages)  latest in thread

Message-ID: <008b01cc6cd3$820581c0$86108540$@devshock.com>
Permalink:  ../008b01cc6cd3$820581c0$86108540$@devshock.com/
Also on:    postgresql.org/message-id/008b01cc6cd3$820581c0$86108540$@devshock.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: aa@devshock.com, craig_james@emolecules.com
  Subject: Re: how fast index works?
  In-Reply-To: <008b01cc6cd3$820581c0$86108540$@devshock.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox