Re: [SQL] query not using index for descending records?

2004-01-30 Thread email lists
Hi, | You probably don't want to do that. The DESC only applies to the | one expression it follows. What you want is probably: | explain select datetime,id from trafficlogs order by | datetime desc,id desc limit 20; This is exactly what I was after - worked a treat! Thanks. Darren

Re: [SQL] query not using index for descending records?

2004-01-29 Thread Bruno Wolff III
On Thu, Jan 29, 2004 at 22:18:08 +1000, email lists [EMAIL PROTECTED] wrote: Limit (cost=0.00..2.31 rows=20 width=12) - Index Scan using idx_trafficlogs_datetime_id on trafficlogs (cost=0.00..1057.89 rows=9172 width=12) (2 rows) however, I am wanting to return the last 20 records. I

Re: [SQL] query not using index for descending records?

2004-01-29 Thread Achilleus Mantzios
O kyrios Bruno Wolff III egrapse stis Jan 29, 2004 : As i see there was a thread http://archives.postgresql.org/pgsql-hackers/2003-05/msg00762.php dealing with this issue, assuming the correct order by should be order by datetime ASC, id DESC. Do you know of any progress for declaring the

Re: [SQL] query not using index for descending records?

2004-01-29 Thread Bruno Wolff III
On Thu, Jan 29, 2004 at 15:29:11 +0200, Achilleus Mantzios [EMAIL PROTECTED] wrote: O kyrios Bruno Wolff III egrapse stis Jan 29, 2004 : As i see there was a thread http://archives.postgresql.org/pgsql-hackers/2003-05/msg00762.php dealing with this issue, assuming the correct order by

Re: [SQL] query not using index for descending records?

2004-01-29 Thread Achilleus Mantzios
O kyrios Bruno Wolff III egrapse stis Jan 29, 2004 : On Thu, Jan 29, 2004 at 15:29:11 +0200, Achilleus Mantzios [EMAIL PROTECTED] wrote: O kyrios Bruno Wolff III egrapse stis Jan 29, 2004 : As i see there was a thread http://archives.postgresql.org/pgsql-hackers/2003-05/msg00762.php

Re: [SQL] query not using index for descending records?

2004-01-29 Thread Stephan Szabo
On Thu, 29 Jan 2004, Bruno Wolff III wrote: On Thu, Jan 29, 2004 at 15:29:11 +0200, Achilleus Mantzios [EMAIL PROTECTED] wrote: O kyrios Bruno Wolff III egrapse stis Jan 29, 2004 : As i see there was a thread http://archives.postgresql.org/pgsql-hackers/2003-05/msg00762.php dealing

Re: [SQL] query not using index for descending records?

2004-01-29 Thread Tom Lane
Stephan Szabo [EMAIL PROTECTED] writes: I'd thought that I'd previously sent a message containing a set of definitions for the reverse opclasses (not meant for inclusion to the system because I was making SQL functions that basically did -normal comparison function to use as the function of

Re: [SQL] query not using index for descending records?

2004-01-29 Thread Stephan Szabo
On Thu, 29 Jan 2004, Tom Lane wrote: Stephan Szabo [EMAIL PROTECTED] writes: I'd thought that I'd previously sent a message containing a set of definitions for the reverse opclasses (not meant for inclusion to the system because I was making SQL functions that basically did -normal

Re: [SQL] query not using index for descending records?

2004-01-29 Thread Tom Lane
Stephan Szabo [EMAIL PROTECTED] writes: Yeah, that's what I figured. I thought it might be useful for people to play with though since at least for the integer/float types writing C versions of the comparitors is easy. I was thinking for real it'd be nice to be able to use the normal