Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id EDF1A650F21 for ; Tue, 1 Jul 2008 16:29:46 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 62886-04-5 for ; Tue, 1 Jul 2008 16:29:35 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.176]) by postgresql.org (Postfix) with ESMTP id 00FC5650ECE for ; Tue, 1 Jul 2008 16:29:27 -0300 (ADT) Received: by py-out-1112.google.com with SMTP id d37so28115pye.29 for ; Tue, 01 Jul 2008 12:29:27 -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=8YRpwkDfTAe8+r6yaO6XYdSzD8mk6O+4HgD6RT37ouQ=; b=B6NNIIfiVeQKGzDCdkO3NdfCovB0Y3+1pVA+Z6mDlfndyVJbTsprrs7Rs8d1gghzbk NHKjq099GLL1G3RZI+Gv0V7LNhiHC1NL7amqq31iD/gxnMkpbLma64cuPi2xY0YlZoRO 8D5+V2b7C94Nhpc+vRNRQc1m757ngkVNyTgK0= 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=mG+aloJ5TKdJHEIh8slHOrnbQCbFJy3FyHZSLZc0qBZKnCptYAz+yhLQnOCE9cwvlN WASBZR8jFWGz9wXZCa4XWtV5gza8VlP1mwLz1dPsin8XGY6ANWcR/kiF8u03IESqXV7C +q5uRE2yvRL4gxY1GKBPOiT3QefRX1m0UkbYc= Received: by 10.114.235.8 with SMTP id i8mr6147556wah.194.1214940566563; Tue, 01 Jul 2008 12:29:26 -0700 (PDT) Received: by 10.114.183.9 with HTTP; Tue, 1 Jul 2008 12:29:26 -0700 (PDT) Message-ID: Date: Tue, 1 Jul 2008 15:29:26 -0400 From: "samantha mahindrakar" To: pgsql-performance@postgresql.org Subject: Select running slow on Postgres 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: 200807/9 X-Sequence-Number: 30609 Hi I have a select statement that runs on a partition having say couple million rows. The tabel has indexes on two colums. However the query uses the non-indexed colums too in its where clause. For example: SELECT lane_id,measurement_start, measurement_end,speed,volume,occupancy,quality,effective_date FROM tss.lane_data_06_08 WHERE lane_id in(select lane_id from lane_info where inactive is null ) AND date_part('hour', measurement_start) between 5 and 23 AND date_part('day',measurement_start)=30 GROUP BY lane_id,measurement_start,measurement_end,speed,volume,occupancy,quality,effective_date ORDER BY lane_id, measurement_start out of this only lane_id and mesaurement_start are indexed. This query will return around 10,000 rows. But it seems to be taking a long time to execute which doesnt make sense for a select statement. It doesnt make any sense to create index for every field we are gonna use in tne where clause. Isnt there any way we can improve the performance? Samantha