Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id C9693145DDC7 for ; Mon, 18 Jun 2012 22:01:44 -0300 (ADT) Received: from mahout.postgresql.org ([98.129.198.123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SgmpD-0005TL-QI for pgsql-bugs@postgresql.org; Tue, 19 Jun 2012 01:01:44 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sgmp0-0003JI-Fj for pgsql-bugs@postgresql.org; Tue, 19 Jun 2012 01:01:31 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1Sgmoz-0002gU-No for pgsql-bugs@postgresql.org; Tue, 19 Jun 2012 01:01:29 +0000 Date: Tue, 19 Jun 2012 01:01:29 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6698: sub-query with join producing out of memory in where clause To: pgsql-bugs@postgresql.org From: armando.miraglia@stud-inf.unibz.it X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/157 X-Sequence-Number: 33384 The following bug has been logged on the website: Bug reference: 6698 Logged by: Armando Miraglia Email address: armando.miraglia@stud-inf.unibz.it PostgreSQL version: 9.1.2 Operating system: Arch Linux/Ubuntu Description: = Hi everybody! Fact: while I was trying to produce a c-function I got an OOM which RhodiumToad helped me to debug. The OOM is reproducible with also standard query. Environment: I tested the POC using 9.1.2 but also 9.2devel compiled "by-hand" Reproducibility: - limit the memory usage ulimit -S -v 500000 - start postgresql postgres -D ../data.ascii/ - run the following query from psql SELECT * = = FROM generate_series(1,1000000) i = = WHERE 100 <=3D (SELECT COUNT(*) = = = FROM unnest(array(select j from generate_series(i-100,i+100) j)) u1 JOIN = = unnest(array(select j from generate_series(i-100,i+100) j)) u2 ON (u1.u1=3Du2.u2)); = = = Error: - psql side: ERROR: out of memory DETAIL: Failed on request of size 828. - server side: ... PortalMemory: 8192 total in 1 blocks; 7888 free (0 chunks); 304 used PortalHeapMemory: 1024 total in 1 blocks; 824 free (0 chunks); 200 used ExecutorState: 458358928 total in 67 blocks; 794136 free (15965 chunks); 457564792 used accumArrayResult: 8192 total in 1 blocks; 5744 free (4 chunks); 2448 used HashTableContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used HashBatchContext: 32768 total in 2 blocks; 8416 free (1 chunks); 24352 used ... As you can see I am using enconding sqlascii. Thanks a lot! Armando Miraglia