Re: Index ot being used

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Madison Kelly <linux(at)alteeve(dot)com>
Cc: Tobias Brox <tobias(at)nordicbet(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Index ot being used
Date: 2005-06-12 15:56:23
Message-ID: 24636.1118591783@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Madison Kelly <linux(at)alteeve(dot)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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Bruno Wolff III 2005-06-12 17:37:32 Re: Index ot being used
Previous Message Madison Kelly 2005-06-12 14:12:27 Re: Index ot being used