Time complexity of statements

Started by Sebastjan Trepcaabout 20 years ago4 messagesgeneral
Jump to latest
#1Sebastjan Trepca
trepca@gmail.com

Hi everybody!

As I understood from books and docs every statement in Postgres takes
O(1) because of it's versioning system, right?

I'm talking about INSERT,UPDATE,SELECT and DELETE statement.

Is it true? or did I get it wrong.

I'm specially interested in UPDATE statement. We'll have lots of them.

Thanks, Sebastjan

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Sebastjan Trepca (#1)
Re: Time complexity of statements

Sebastjan Trepca <trepca@gmail.com> writes:

As I understood from books and docs every statement in Postgres takes
O(1) because of it's versioning system, right?

Finding an existing row is not O(1), so this is not the case for
anything but INSERT. You also have to consider index update costs,
foreign key checking costs if applicable, etc etc.

regards, tom lane

#3Peter Eisentraut
peter_e@gmx.net
In reply to: Sebastjan Trepca (#1)
Re: Time complexity of statements

Am Dienstag, 14. Februar 2006 16:13 schrieb Sebastjan Trepca:

As I understood from books and docs every statement in Postgres takes
O(1) because of it's versioning system, right?

Absolutely not.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

#4Sebastjan Trepca
trepca@gmail.com
In reply to: Peter Eisentraut (#3)
Re: Time complexity of statements

Ok, thanks. I guess that was a stupid question, sorry :)

I guess we'll have to use INSERTs instead of UPDATEs.

Sebastjan

Show quoted text

On 2/14/06, Peter Eisentraut <peter_e@gmx.net> wrote:

Am Dienstag, 14. Februar 2006 16:13 schrieb Sebastjan Trepca:

As I understood from books and docs every statement in Postgres takes
O(1) because of it's versioning system, right?

Absolutely not.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/