Re: TABLESAMPLE usage - Mailing list pgsql-general

From Simon Riggs
Subject Re: TABLESAMPLE usage
Date
Msg-id CANP8+jL-C3dmwFyitfQh0SY-tvNdvZVR=SdbAivM9FSL7_EkXg@mail.gmail.com
Whole thread Raw
In response to Re: TABLESAMPLE usage  (Matija Lesar <matija.lesar@gmail.com>)
Responses Re: TABLESAMPLE usage  (Tom Smith <tomsmith1989sk@gmail.com>)
List pgsql-general
On 25 January 2016 at 09:44, Matija Lesar <matija.lesar@gmail.com> wrote:
 
you can accomplish this with row_number():

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/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: Possible to dump/load a database from within psql?
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Possible to dump/load a database from within psql?