X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 6A2929FA5D2 for ; Fri, 9 Jun 2006 06:52:49 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 10910-01 for ; Fri, 9 Jun 2006 06:52:45 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id A972F9FA61D for ; Fri, 9 Jun 2006 06:52:45 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id EDB0031DC6; Fri, 9 Jun 2006 11:52:43 +0200 (MET DST) From: "Andrus" X-Newsgroups: pgsql.performance Subject: Re: Why date index is not used Date: Fri, 9 Jun 2006 12:52:21 +0300 Organization: Hub.Org Networking Services Lines: 25 Message-ID: References: <196.1149794455@sss.pgh.pa.us> X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-RFC2646: Format=Flowed; Original To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/108 X-Sequence-Number: 19465 Tom, > Because it doesn't help --- the system still has to do the sort. It can help a lot in this case. kuupaev is sales date kellaaeg is sales time Postgres can use kuupaev index to fetch first 100 rows plus a number of more rows whose kellaaeg value is equal to kellaaeg in 100 th row. I have 500 sales per day. So it can fetch 600 rows using index on kuupaev column. After that it can sort those 600 rows fast. Currently it sorts blindly all 54000 rows in table. > You'd need a two-column index on both of the ORDER BY columns to avoid > sorting. Thank you. It works. Andrus.