Re: limit order by performance issue - Mailing list pgsql-performance

From Karl Denninger
Subject Re: limit order by performance issue
Date
Msg-id 507DB9BE.6070906@denninger.net
Whole thread Raw
In response to limit order by performance issue  (Pedro Jiménez <p.jimenez@ismsolar.com>)
Responses Re: limit order by performance issue  (Marti Raudsepp <marti@juffo.org>)
List pgsql-performance
Put an index on time_stamp (I assume there is one on id_signal already)

On 10/15/2012 12:44 PM, Pedro Jiménez wrote:
Hello,
  I'm trying to do a simple SQL query over Postgresl 9.0 running on Ubuntu.

I have a large table (over 100 million records) with three fields, id_signal (bigint), time_stamp (timestamp) and var_value (float).

My query looks like this:

select var_value from ism_floatvalues where id_signal = 29660 order by time_stamp desc limit 1;

So I want to select the last value from a determinated ID (is_signal).

This query runs FOREVER, while if I delete "limit 1" it runs instantly....

Any help?

Regards.





--
-- Karl Denninger
The Market Ticker ®
Cuda Systems LLC

pgsql-performance by date:

Previous
From: Shaun Thomas
Date:
Subject: Re: limit order by performance issue
Next
From: Merlin Moncure
Date:
Subject: Re: LIKE op with B-Tree Index?