pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Arjen van der Meijden <acmmailing@tweakers.net>
To: Thomas Finneid <tfinneid@student.matnat.uio.no>
Cc: pgsql-performance@postgresql.org
Subject: Re: insert vs select into performance
Date: Tue, 17 Jul 2007 21:53:51 +0200
Message-ID: <469D1E4F.5090805@tweakers.net> (raw)
In-Reply-To: <469D1AD3.9030004@ifi.uio.no>
References: <469D1AD3.9030004@ifi.uio.no>

Have you also tried the COPY-statement? Afaik select into is similar to 
what happens in there.

Best regards,

Arjen

On 17-7-2007 21:38 Thomas Finneid wrote:
> Hi
> 
> I was doing some testing on "insert" compared to "select into". I 
> inserted 100 000 rows (with 8 column values) into a table, which took 14 
> seconds, compared to a select into, which took 0.8 seconds.
> (fyi, the inserts where batched, autocommit was turned off and it all 
> happend on the local machine)
> 
> Now I am wondering why the select into is that much faster?
> Does the select into translate into a specially optimised function in c 
> that can cut corners which a insert can not do (e.g. lazy copying), or 
> is it some other reason?
> 
> The reason I am asking is that select into shows that a number of rows 
> can be inserted into a table quite a lot faster than one would think was 
> possible with ordinary sql. If that is the case, it means that if I 
> write an pl-pgsql insert function in C instead of sql, then I can have 
> my db perform order of magnitude faster.
> 
> Any comments?
> 
> regards
> 
> thomas
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
> 



view thread (22+ messages)  latest in thread

Message-ID: <469D1E4F.5090805@tweakers.net>
Permalink:  ../469D1E4F.5090805@tweakers.net/
Also on:    postgresql.org/message-id/469D1E4F.5090805@tweakers.net

 · 

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: acmmailing@tweakers.net, tfinneid@student.matnat.uio.no
  Subject: Re: insert vs select into performance
  In-Reply-To: <469D1E4F.5090805@tweakers.net>

* 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