pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Madison Kelly <linux@alteeve.com>
Cc: Tobias Brox <tobias@nordicbet.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Index ot being used
Date: Sun, 12 Jun 2005 11:56:23 -0400
Message-ID: <24636.1118591783@sss.pgh.pa.us> (raw)
In-Reply-To: <42AC42CB.8050703@alteeve.com>
References: <1825.216.209.137.1.1118419819.squirrel@mail.alteeve.com>
	<20050610155535.GO8451@tobias.nordicbet.com>
	<42AC42CB.8050703@alteeve.com>

Madison Kelly <linux@alteeve.com> writes:
>    Here is my full query:

> tle-bu=> EXPLAIN ANALYZE SELECT file_name, file_parent_dir, file_type 
> FROM file_info_7 WHERE file_type='d' ORDER BY file_parent_dir ASC, 
> file_name ASC;

>    This is my index (which I guess is wrong):

> tle-bu=> \d file_info_7_display_idx
>   Index "public.file_info_7_display_idx"
>       Column      |         Type
> -----------------+----------------------
>   file_type       | character varying(2)
>   file_parent_dir | text
>   file_name       | text
> btree, for table "public.file_info_7"

The index is fine, but you need to phrase the query as

	... ORDER BY file_type, file_parent_dir, file_name;

(Whether you use ASC or not doesn't matter.)  Otherwise the planner
won't make the connection to the sort ordering of the index.

			regards, tom lane



view thread (31+ messages)  latest in thread

Message-ID: <24636.1118591783@sss.pgh.pa.us>
Permalink:  ../24636.1118591783@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/24636.1118591783@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, linux@alteeve.com, tobias@nordicbet.com
  Subject: Re: Index ot being used
  In-Reply-To: <24636.1118591783@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox