Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 68AC92E0037 for ; Wed, 16 Apr 2008 18:14:15 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 09955-10 for ; Wed, 16 Apr 2008 18:14:13 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.179]) by developer.postgresql.org (Postfix) with ESMTP id 2847E2E0030 for ; Wed, 16 Apr 2008 18:14:12 -0300 (ADT) Received: by wa-out-1112.google.com with SMTP id n7so4555511wag.5 for ; Wed, 16 Apr 2008 14:14:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=h2vevK6yZa5cMOPGKq0YZnmST/LBd9Dl1j6JXeVbn2I=; b=kMao6rE38rZ8PF1Jfl+5C7IUJpZJ7iyfnUuPFpeRi4QuyW92spNxZX7f+aHETR2wEYjxRQq4qW6jZnOEGVt9s9Tv0JGrG/vRoHiGNBCWIUxkrcgMuRHhwx/Zr/DsZxd4nYL5CAvPwYpmlmVnIIJC/nbcXG6MptyJhYSWfZYBrWI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=ixJPsSl8sbpvwIkwjERew9JTTtL7SKYYxLLhvUAoTxW4DLkNPK0g7LMLoEZHTdYGmd58OTu68U43aw866zSTnRJz3vC0t0bqrm84p9HUt57NgFUjjEXulMZJSjamKhhcb+P2n8AI9K3zr7eYyKOTSi0bZfkXPg2WaeYyBtDkKrw= Received: by 10.114.123.19 with SMTP id v19mr616552wac.168.1208380451284; Wed, 16 Apr 2008 14:14:11 -0700 (PDT) Received: by 10.114.181.19 with HTTP; Wed, 16 Apr 2008 14:14:11 -0700 (PDT) Message-ID: Date: Wed, 16 Apr 2008 17:14:11 -0400 From: "samantha mahindrakar" To: pgsql-performance@postgresql.org Subject: Query running slow MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200804/219 X-Sequence-Number: 29712 Hi.... Iam finding the following query is working a bit slow: EXECUTE '(SELECT ARRAY(SELECT DISTINCT date_part(''day'', measurement_start) FROM ' || gettablestring(dates)|| ' WHERE lane_id IN (' || lanesidarr || ')))' INTO temparr; This function is trying to find all the days in a prticular month whihc has data for the particular lane and put it in an array...which can be used later. gettablestring(dates) returns the partition name from which the data needs to be extracted. These partitions have index on the measurement_start field. lanesidarr is a lane number. The partition has an index on this field to. Could anyone give me some hints???/ Thanks Sam