pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Gaab <A.Gaab@scanlab.de>
To: pgsql sql <pgsql-sql@postgresql.org>
Cc: Hans Joachim Münzer <H.Muenzer@scanlab.de>
Subject: unnesting of array of different size explodes memory
Date: Wed, 13 Apr 2011 11:15:38 +0200
Message-ID: <48DA836F3865C54B8FBF424A3B775AF667239FFDEF@Exchange-Server> (raw)

Hi,

I need to sum up the elements of two arrays. Most arrays were of the same size, thus I just unnested the arrays in one table and grouped the results in a loop for every row. When two arrays of different size (1200 and 1300) were processed, the memory usage exploded and the query was killed by the kernel.

As I now understand, the following query leads to 12 results, not just 4 (or 3...):

SELECT unnest(ARRAY[1,2,3]), unnest(ARRAY[4,5,6,7]);

Why could postgres use as much memory till the kernel complained when unnesting 1200 and 1300 elements resulting in 1.6e6 rows. Are there settings to prevent this such as "work_mem"?

Regards,
Andreas

___________________________________________________________________________

SCANLAB AG
Dr. Andreas Simon Gaab
Entwicklung * R & D

Siemensstr. 2a * 82178 Puchheim * Germany
Tel. +49 (89) 800 746-513 * Fax +49 (89) 800 746-199
mailto:a.gaab@scanlab.de * www.scanlab.de<http://www.scanlab.de;

Amtsgericht München: HRB 124707 * USt-IdNr.: DE 129 456 351
Vorstand: Georg Hofner (Sprecher), Christian Huttenloher, Norbert Petschik
Aufsichtsrat (Vorsitz): Dr. Hans J. Langer
___________________________________________________________________________

Besuchen Sie uns auf der / Meet us at
LASER World of PHOTONICS 2011
Munich, Germany
May 23 - 26, 2011
Hall C2, Booth 461

view thread (3+ messages)  latest in thread

Message-ID: <48DA836F3865C54B8FBF424A3B775AF667239FFDEF@Exchange-Server>
Permalink:  ../48DA836F3865C54B8FBF424A3B775AF667239FFDEF@Exchange-Server/
Also on:    postgresql.org/message-id/48DA836F3865C54B8FBF424A3B775AF667239FFDEF@Exchange-Server

 · 

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-sql@postgresql.org
  Cc: A.Gaab@scanlab.de, H.Muenzer@scanlab.de
  Subject: Re: unnesting of array of different size explodes memory
  In-Reply-To: <48DA836F3865C54B8FBF424A3B775AF667239FFDEF@Exchange-Server>

* 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