Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TLJOk-0005rU-LW for pgsql-performance@postgresql.org; Mon, 08 Oct 2012 19:53:55 +0000 Received: from lrosenman-1-pt.tunnel.tserv8.dal1.ipv6.he.net ([2001:470:1f0e:3ad::2] helo=thebighonker.lerctr.org) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TLJOg-0008DS-NT for pgsql-performance@postgresql.org; Mon, 08 Oct 2012 19:53:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lerctr.org; s=lerami; h=Message-ID:References:In-Reply-To:Subject:To:From:Date:Content-Transfer-Encoding:Content-Type:MIME-Version; bh=IHA9DcNb3yqDXg059s0M4nZDxpdFkUaxGHxABJovnDA=; b=RuPqM7lKJkod6mHjpnQeuzN03omcgM1m+GBTHPZ1S9p9Ph1Gp5GCHv1CCfNafbyzJg3tlYiBO+m0ayWCHNHAWerNSkN43bzpLUFWhLmkAajHc/EGmEDYAiYkMvRmyeUVzHEmJGo0OPsuxZkx4BokxTCdt8RK22Oq/WMjgD6Y6vc=; Received: from localhost.lerctr.org ([127.0.0.1]:51901 helo=webmail.lerctr.org) by thebighonker.lerctr.org with esmtpa (Exim 4.80 (FreeBSD)) (envelope-from ) id 1TLJOe-000NAl-B5 for pgsql-performance@postgresql.org; Mon, 08 Oct 2012 14:53:48 -0500 Received: from [32.97.110.60] by webmail.lerctr.org with HTTP (HTTP/1.1 POST); Mon, 08 Oct 2012 14:53:48 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 08 Oct 2012 14:53:48 -0500 From: Larry Rosenman To: Subject: Re: Scaling 10 million records in PostgreSQL table In-Reply-To: References: Message-ID: <0465ecd0abdd8c64e254b08ae327f566@webmail.lerctr.org> X-Sender: ler@lerctr.org User-Agent: Roundcube Webmail/0.8.1 X-Spam-Score: -5.0 (-----) X-LERCTR-Spam-Score: -5.0 (-----) X-Spam-Report: SpamScore (-5.0/5.0) ALL_TRUSTED=-1, BAYES_00=-1.9, RP_MATCHES_RCVD=-2.138 X-LERCTR-Spam-Report: SpamScore (-5.0/5.0) ALL_TRUSTED=-1, BAYES_00=-1.9, RP_MATCHES_RCVD=-2.138 X-Pg-Spam-Score: -2.0 (--) X-Archive-Number: 201210/54 X-Sequence-Number: 48013 On 2012-10-08 10:26, Navaneethan R wrote: > Hi all, > > I have 10 million records in my postgres table.I am running the > database in amazon ec2 medium instance. I need to access the last > week > data from the table. > It takes huge time to process the simple query.So, i throws time out > exception error. > > query is : > select count(*) from dealer_vehicle_details where modified_on > between '2012-10-01' and '2012-10-08' and dealer_id=270001; > > After a lot of time it responds 1184 as count > > what are the ways i have to follow to increase the performance of > this query? > > The insertion also going parallel since the daily realtime updation. > > what could be the reason exactly for this lacking performace? What indexes do you have on your table? I'll bet none. What does an explain select count(*) from dealer_vehicle_details where modified_on between '2012-10-01' and '2012-10-08' and dealer_id=270001; show? I have a 380Million row table, with LOTS of indexing, and we perform very well. Without indexes, the query had to sequential scan all 10 million rows. That's going to be bad on ANY database.