Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 104F963267B for ; Thu, 8 Apr 2010 11:03:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 29957-08 for ; Thu, 8 Apr 2010 14:03:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by mail.postgresql.org (Postfix) with ESMTP id 69AEA6322C9 for ; Thu, 8 Apr 2010 11:03:32 -0300 (ADT) Received: from webserv.wug.de ([194.25.154.138]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0MPqmw-1Nw2ZX43D0-004YUw; Thu, 08 Apr 2010 16:03:30 +0200 Received: from kretschmer by webserv.wug.de with local (Exim 3.36 #1) id 1NzsKP-0000OK-00 for pgsql-performance@postgresql.org; Thu, 08 Apr 2010 16:03:29 +0200 Date: Thu, 8 Apr 2010 16:03:29 +0200 From: "A. Kretschmer" To: pgsql-performance@postgresql.org Subject: Re: Query Optimization Message-ID: <20100408140329.GD29013@a-kretschmer.de> References: <4BBDD2F3.7030701@digsys.bg> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4BBDD2F3.7030701@digsys.bg> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! User-Agent: Mutt/1.5.9i X-Provags-ID: V01U2FsdGVkX1+9IZpR1Ag3NKgiTOLIUyFQrfiYqnTmGU8h/3/ 2FdfwXwLvMrI8UnSgPxlBJIIMN9BdTD47Y+NiLuyTcm69byxwK u7i12F+uH2mfo6g6+K7aA== X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=-10 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 201004/104 X-Sequence-Number: 38354 In response to Kaloyan Iliev Iliev : > Hi, > Can anyone suggest why this query so slow. > -> Index Scan using > ms_commands_history_ms_device_id_idx on ms_commands_history ch > (cost=0.00..4.33 rows=1 width=8) (actual time=0.163..25254.004 rows=9807 > loops=1) Estimated rows: 1, actual rows: 9807, that's a BIG difference and, maybe, your problem. Btw.: your explain is hard to read (line-wrapping). It's better to attach the explain as an own file... Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 2EB0 389D 1DC2 3172 0C99