Re: fastes way to retrieve segmented without using loop

From: Melvin Davidson <melvin6925(at)gmail(dot)com>
To: Tom Smith <tomsmith1989sk(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: fastes way to retrieve segmented without using loop
Date: 2015-08-23 21:38:44
Message-ID: CANu8FiyRkBAwtMGj-=YUc4uJEmMyo0HvrWO9bqVUHr4Er7GKXQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Well, I would say the following might work:

SELECT *
FROM table
WHERE t >=1
LIMIT 99998;

On Sun, Aug 23, 2015 at 5:05 PM, Tom Smith <tomsmith1989sk(at)gmail(dot)com> wrote:

> Hello:
>
> I have a time series table,
> using below sql, loop (psque code), I can get one row for each hour
>
> for( H=1: H< 99999; H++){
> select * from table where t >= H and t < H+1 limit 1
> }
>
> t (time column) is indexed).
>
> Is there a better way to use a issue a SINGLE SQL
> with an array of time start/end pair
> so it will be executed once to send back result, which would be much faster
> than issuing sql again and again (even with prepared statement and using
> sql function).
>
> Thanks in Advance
>

--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Melvin Davidson 2015-08-23 21:43:18 Re: fastes way to retrieve segmented without using loop
Previous Message Tom Smith 2015-08-23 21:05:55 fastes way to retrieve segmented without using loop