Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5sqC-00064U-UY for pgsql-general@arkaria.postgresql.org; Fri, 28 Sep 2018 13:29:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g5sqA-00081g-Ha for pgsql-general@arkaria.postgresql.org; Fri, 28 Sep 2018 13:29:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5sqA-00081T-9O for pgsql-general@lists.postgresql.org; Fri, 28 Sep 2018 13:29:54 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g5sq8-0005ox-Ap for pgsql-general@postgresql.org; Fri, 28 Sep 2018 13:29:53 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 6155E21C89; Fri, 28 Sep 2018 09:29:50 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 28 Sep 2018 09:29:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=NPsGiAgDs6EkauEoQbxIYAjEx5ncg bYo0OHjyZdM1i4=; b=LWmarJkBNF7LCHGuqjZMytCumZdv2vOvoVY9JsfgjlH92 SBIHUeVCgGOInm898dHB0f9OhfpPLtexLA2hErWvYeuOQqwCN58h/Yscu3gtCQlz 9Kp19kUQeXpIAe70ZRn8QsR1xFo1JcCsLtIabPX34JHVyoUIsKLHcY2Ni5XkawJv DSFH1lLnx9VUE1SWM3n925CyvHueDxGrQioCdwaBr4VWwSzbVyyI6R8V28J+rFfm NHa9e1gjIc/yTB+UeLuyePKVvTQvD8WeXLBb51G/7LdY4fJAkcllX+j7cZEdr5ey Fg3yNH6FR+NFrRGUHbi1UfqSPAa3Y3QKx48LWgzfQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=NPsGiA gDs6EkauEoQbxIYAjEx5ncgbYo0OHjyZdM1i4=; b=SEEVkQ7ZtwIsLrKiVIp5Wg s8GbPw42lGKyPKNXibgty8dvDdOFkCm5AUavCT8B0oZ/j8AoHqE3wsij6ASQdmk1 Ncspr2vcQx2s+dU22KlonxKNz/3R9XQpTIkXp8rzfkTzqNkc8ablJt4BcRBfGfTp rD212Lma2LeOWHSH+8ycb9ActpDbPUSp67KEXP1tcXJxVKw6x4/DVNNbE7ZiK+Jr YmpylAOvv+OnZbrd+uqjfbO6UIgsPhpUtlXWgYAaDt1VA7sTmHGXqeoUw7fPGPVk CQUsecBAMW9EkHI1wEDmC+bsBR/hQYe2uJCK6XUSPQrhmIl8HT9Wui+vwPs+Yiew == X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 69759E474F; Fri, 28 Sep 2018 09:29:49 -0400 (EDT) Subject: Re: Why my query not using index to sort? To: Arup Rakshit , Ravi Krishna Cc: pgsql-general@postgresql.org References: <1179827344.882330.1538140134266.ref@mail.yahoo.com> <1179827344.882330.1538140134266@mail.yahoo.com> From: Adrian Klaver Message-ID: Date: Fri, 28 Sep 2018 06:29:48 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 9/28/18 6:19 AM, Arup Rakshit wrote: > Hi Ravi, > > > Yes you are right. It seems it is doing sorting in memory by name. But I > have `name` column in index. You are looking for the vessels.company_id not vessels.name so not sure why you expect an index lookup on name? > > > Thanks, > > Arup Rakshit > ar@zeit.io > > > >> On 28-Sep-2018, at 6:38 PM, Ravi Krishna > > wrote: >> >> >>> Is there anyway, I can improve the sorting so that it can use the index ? >> >> Are you telling that why PG is not simply reading the data from the >> index (which is already in sorted >> order)? >> > -- Adrian Klaver adrian.klaver@aklaver.com