Skip to content

Instantly share code, notes, and snippets.

@yulisunny
Created April 29, 2016 15:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save yulisunny/b263bb0f00b81ac9f036faac97cf9caa to your computer and use it in GitHub Desktop.
WITH persisted_rate AS (
SELECT
date_trunc('minute', persisted_time) AS persisted_minute,
count(*) AS num_persisted
FROM persistent_queue_table
GROUP BY persisted_minute
),
polled_rate AS (
SELECT
date_trunc('minute', poll_time) AS poll_minute,
count(*) AS num_polled
FROM persistent_queue_table
GROUP BY poll_minute
),
SELECT
persisted_minute AS minute,
num_persisted,
num_polled
FROM persisted_rate
INNER JOIN polled_rate ON persisted_minute = poll_minute
ORDER BY minute;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment