Re: [SQL] Index usage in order by with multiple columns in order-by-clause

2007-08-11 Thread Andreas Joseph Krogh
On Saturday 11 August 2007 21:55:49 Tom Lane wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > > On Friday 10 August 2007 23:30:14 Tom Lane wrote: > >> Reverse-sorted index columns are possible but not well supported in > >> existing PG releases (you need a custom operator class, and the

Re: [SQL] Index usage in order by with multiple columns in order-by-clause

2007-08-11 Thread Tom Lane
Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > On Friday 10 August 2007 23:30:14 Tom Lane wrote: >> Reverse-sorted index columns are possible but not well supported in >> existing PG releases (you need a custom operator class, and the planner >> is not all that bright about using them). 8.3 wi

Re: [SQL] Index usage in order by with multiple columns in order-by-clause

2007-08-11 Thread Andreas Joseph Krogh
On Saturday 11 August 2007 21:05:22 hubert depesz lubaczewski wrote: > On Fri, Aug 10, 2007 at 04:53:12PM +0200, Andreas Joseph Krogh wrote: > > I have the following test-case: > > > > CREATE TABLE test( > > name varchar PRIMARY KEY, > > value varchar NOT NULL, > > created timestamp not null > > );

Re: [SQL] Index usage in order by with multiple columns in order-by-clause

2007-08-11 Thread hubert depesz lubaczewski
On Fri, Aug 10, 2007 at 04:53:12PM +0200, Andreas Joseph Krogh wrote: > I have the following test-case: > > CREATE TABLE test( > name varchar PRIMARY KEY, > value varchar NOT NULL, > created timestamp not null > ); > > create index test_lowernamevalue_idx ON test ((lower(name) || lower(value)));

Re: [SQL] Index usage in order by with multiple columns in order-by-clause

2007-08-11 Thread Andreas Joseph Krogh
On Friday 10 August 2007 23:30:14 Tom Lane wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > > Is there a way I can have multiple columns in the ORDER BY clause, each > > with different ASC/DESC-order and still use an index to speed up sorting? > > A btree index isn't magic, it's just an

Re: [SQL] Index usage in order by with multiple columns in order-by-clause

2007-08-10 Thread Tom Lane
Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > Is there a way I can have multiple columns in the ORDER BY clause, each with > different ASC/DESC-order and still use an index to speed up sorting? A btree index isn't magic, it's just an ordered list of entries. So you can't just randomly flip t

[SQL] Index usage in order by with multiple columns in order-by-clause

2007-08-10 Thread Andreas Joseph Krogh
I have the following test-case: CREATE TABLE test( name varchar PRIMARY KEY, value varchar NOT NULL, created timestamp not null ); create index test_lowernamevalue_idx ON test ((lower(name) || lower(value))); create index test_lowernamevaluecreated_idx ON test ((lower(name) || lower(value)), cre