Search Postgresql Archives

Re: Best approach for a "gap-less" sequence

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In article <20060814162836.58963.qmail@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Richard Broersma Jr <rabroersma@xxxxxxxxx> writes:

> I am curious, can you calculate something like this using only sql? Or you you need to employee a
> procedural language like plpsgql?

You could use something like

  SELECT (SELECT count(*) FROM tbl t2 WHERE t2.id < t1.id), whatever
  FROM tbl t1

but correlated subqueries are slow; thus incrementing the counter in
the application would be faster for huge reports.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux