| From: | Simon Riggs <simon(at)2ndQuadrant(dot)com> |
|---|---|
| To: | Matija Lesar <matija(dot)lesar(at)gmail(dot)com> |
| Cc: | Tom Smith <tomsmith1989sk(at)gmail(dot)com>, Vik Fearing <vik(at)2ndquadrant(dot)fr>, PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: TABLESAMPLE usage |
| Date: | 2016-01-25 10:56:41 |
| Message-ID: | CANP8+jL-C3dmwFyitfQh0SY-tvNdvZVR=SdbAivM9FSL7_EkXg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On 25 January 2016 at 09:44, Matija Lesar <matija(dot)lesar(at)gmail(dot)com> wrote:
> you can accomplish this with row_number()
> <http://www.postgresql.org/docs/8.4/static/functions-window.html#FUNCTIONS-WINDOW-TABLE>
> :
>
> WITH data_cte as (
> SELECT
> id,
> clock_timestamp() as ctimestamp
> FROM generate_series(1,1000) as id
> )
> SELECT
> *
> FROM
> (SELECT
> id,
> ctimestamp,
> row_number() OVER (ORDER BY ctimestamp) as rownum
> FROM data_cte
> ) as data_withrownumbers
> WHERE
> rownum%100=1;
>
You can, but its not very fast.
--
Simon Riggs http://www.2ndQuadrant.com/
<http://www.2ndquadrant.com/>
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joshua D. Drake | 2016-01-25 10:57:38 | Re: Possible to dump/load a database from within psql? |
| Previous Message | Raymond O'Donnell | 2016-01-25 10:56:01 | Re: Possible to dump/load a database from within psql? |