Re: cheapest way to access every 15th row in table ordered by timestamp column

From: Subodh Deshpande <deshpande.subodh_at_gmail.com>
Date: Tue, 1 Feb 2011 20:48:47 +0530
Message-ID: <AANLkTinS3WbMagOHwKUMo4C1Crq3zK_LxkhH8579ErTS_at_mail.gmail.com>



just a random suggestion...from 9i onwards oracle has introduced datatype timestamp..are you using that..and is your table goign to be indexed on it and you will be also using that index in your query...then you may get more accurate results..

I am not so sure about use of rownum, result set will change if their multiple indexes and you you use rownum..

for timestamp data type you may refer following url..

http://ss64.com/ora/syntax-datatypes.html thanks..subodh
On 19 January 2011 21:50, Stephens, Chris <Chris.Stephens_at_adm.com> wrote:

> 11.2.0.2 on Linux 5
>
>
>
> We have a lab instrument recording information every 2 seconds into a
> table.
>
>
>
> The scientists pull that data into excel for analysis (I hope to look at
> this excel spreadsheet in the very near future now that I’ve read chapter 9
> of Pro Oracle SQL).
>
>
>
> They are requesting a view that picks out every 15th row of data going back
> 30 days.
>
>
>
> Can anyone think of a more efficient way to do it than this:
>
>
>
> SELECT x.col,
>
> x.t_stamp
>
> FROM ( SELECT col,
>
> t_stamp
>
> rownum rn
>
> FROM t
>
> WHERE t_stamp >= TRUNC( SYSDATE - 30 )) x
>
> WHERE MOD( x.rn, 15 ) = 0;
>
>
>
>
>
> It feels like there should be a better way to do it.
>
>
>
> chris
>
> CONFIDENTIALITY NOTICE:
> This message is intended for the use of the individual or entity to which
> it is addressed and may contain information that is privileged, confidential
> and exempt from disclosure under applicable law. If the reader of this
> message is not the intended recipient or the employee or agent responsible
> for delivering this message to the intended recipient, you are hereby
> notified that any dissemination, distribution or copying of this
> communication is strictly prohibited. If you have received this
> communication in error, please notify us immediately by email reply.
>
>
>

-- 
==============================
DO NOT FORGET TO SMILE TODAY
==============================

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Feb 01 2011 - 09:18:47 CST

Original text of this message