insert vs select into performance

От: Thomas Finneid
Тема: insert vs select into performance
Дата: ,
Msg-id: 469D1AD3.9030004@ifi.uio.no
(см: обсуждение, исходный текст)
Ответы: Re: insert vs select into performance  (Michael Glaesemann)
Re: insert vs select into performance  (Arjen van der Meijden)
Re: insert vs select into performance  (PFC)
Список: pgsql-performance

Скрыть дерево обсуждения

insert vs select into performance  (Thomas Finneid, )
 Re: insert vs select into performance  (Michael Glaesemann, )
  Re: insert vs select into performance  (Tom Lane, )
   Re: insert vs select into performance  (Thomas Finneid, )
    Re: insert vs select into performance  (Michael Stone, )
     Re: insert vs select into performance  (Adriaan van Os, )
      Re: insert vs select into performance  (Heikki Linnakangas, )
  Re: insert vs select into performance  (Thomas Finneid, )
   Re: insert vs select into performance  (Michael Stone, )
   Re: insert vs select into performance  (Mark Lewis, )
    Re: insert vs select into performance  (Thomas Finneid, )
   Re: insert vs select into performance  (Michael Glaesemann, )
    Re: insert vs select into performance  (Thomas Finneid, )
 Re: insert vs select into performance  (Arjen van der Meijden, )
  Re: insert vs select into performance  (Thomas Finneid, )
   Re: insert vs select into performance  (Michael Stone, )
    Re: insert vs select into performance  (Thomas Finneid, )
     Re: insert vs select into performance  (Michael Stone, )
 Re: insert vs select into performance  (PFC, )
  Re: insert vs select into performance  (Thomas Finneid, )
   Re: insert vs select into performance  (PFC, )
    Re: insert vs select into performance  (Thomas Finneid, )

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


В списке pgsql-performance по дате сообщения:

От: Ron Mayer
Дата:
Сообщение: ionice to make vacuum friendier?
От: Adriaan van Os
Дата:
Сообщение: Re: TRUNCATE TABLE