Re: SELECTing every Nth record for better performance

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SELECTing every Nth record for better performance
Date: 2009-12-04 10:25:34
Message-ID: 20091204102534.GC26658@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In response to Ivan Voras :
> A. Kretschmer wrote:
> >In response to Tom :
> >>I have a big table that is used for datalogging. I'm designing
> >>graphing interface that will visualise the data. When the user is
> >>looking at a small daterange I want the database to be queried for all
> >>records, but when the user is 'zoomed out', looking at an overview, I
> >>want run a query that skips every nth record and returns a managable
> >>dataset that still gives a correct overview of the data without
> >>slowing the programme down. Is there an easy way to do this that I
> >>have overlooked? I looked at:
> >
> >
> >Do you have 8.4? If yes:
> >
> >test=# create table data as select s as s from generate_Series(1,1000) s;
> >SELECT
> >
> >
> >
> >test=*# select s from (select *, row_number() over (order by s) from
> >data) foo where row_number % 3 = 0 limit 10;
>
> Won't this still read in the entire table and only then filter the
> records out?

Yes.

But i think, the problem is the graphing interface. He wants anly a
'zoomed out' - overview, he needs a 'managable dataset'.

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG: 0x31720C99, 1006 CCB4 A326 1D42 6431 2EB0 389D 1DC2 3172 0C99

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Grzegorz Jaśkiewicz 2009-12-04 10:26:41 Re: SELECTing every Nth record for better performance
Previous Message Ivan Voras 2009-12-04 10:15:23 Re: SELECTing every Nth record for better performance