Re: Result set granularity..

From: Shridhar Daithankar <shridhar_daithankar(at)persistent(dot)co(dot)in>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Result set granularity..
Date: 2003-09-29 07:42:00
Message-ID: 200309291312.00744.shridhar_daithankar@persistent.co.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

On Saturday 27 September 2003 18:41, Rasmus Aveskogh wrote:
> Hi,
>
> Since I went from Oracle to PostgreSQL I've been missing the "invisable"
> column 'rownum'. I often used it to lower the granularity of my data.
> For example, say I have a large table containing some sort of statistical
> data and want to plot a graph using it.
> If the graph is 600 pixels wide I might as well lower the granularity of
> my incoming data to 600 measure points before plotting.
>
> In Oracle I used to do this by using the modulus operator on the rownum
> column as a restriction.
>
> SELECT <column> FROM <table> WHERE mod(rownum, 5) = 0;
>
> The query above would give me every fifth row of the original result set
> and would save me from sending the data over my database connection and do
> the lowering of the granularity in the application.
>
> I have two questions, one dependent on the answer on the other one..
>
> 1) Is it possible to achieve this any other _easy_ way?
> Perhaps it would be feasible to write a wrapper using a counter which
> makes the SELECT and then return every fifth row to the SELECT calling the
> wrapper. But then I assume the data still has to "travel" one step which
> puts on some overhead.

First of all there is oid which you can use but it is not strictly unique.
It's limited to 4GB and wraps around.

I would rather say declare a cursor and move the pointer as and when required.
Sice you aren't retrieving large part of rows, that loop should be cheap
enough.

HTH

Shridhar

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gezeala 'Eyah' Bacuo II 2003-09-29 07:47:05 numeric rounding
Previous Message Relaxin 2003-09-29 07:21:43 Re: downloading latest source from cvs

Browse pgsql-sql by date

  From Date Subject
Next Message marcello miorelli 2003-09-29 11:16:12
Previous Message shyamperi 2003-09-29 07:19:50 Change of the datatype of a column