Re: limit order by performance issue

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Pedro Jiménez <p(dot)jimenez(at)ismsolar(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: limit order by performance issue
Date: 2012-10-16 19:23:34
Message-ID: CAFj8pRBKGMCyGR8uAhz0RkrXqa+06TOp1j52aCPVzeYAs+hmng@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

2012/10/15 Pedro Jiménez <p(dot)jimenez(at)ismsolar(dot)com>:
> 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....

did you ANALYZE your tables?

Can you send EXPLAIN ANALYZE result of both queries?

Regards

Pavel Stehule

>
> Any help?
>
> Regards.
>
>
>
>
> --
> Sent via pgsql-performance mailing list (pgsql-performance(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-performance

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Shaun Thomas 2012-10-16 19:28:15 Re: limit order by performance issue
Previous Message Jeff Janes 2012-10-16 17:38:34 Re: Guide to Posting Slow Query Questions