Tuesday, May 31, 2016

PostgreSQL: pgq

Ticker uses following rules by default:
  1. Batch is made when there are more than 500 new events (ticker_max_count)
  2. Batch is made when there are any number of new events and 3 seconds have passed since last batch (ticker_max_lag)
  3. Batch is made if there are no new events, but 1 minute has passed since last batch (ticker_idle_period)
https://kaiv.wordpress.com/2007/10/19/skytools-database-scripting-framework-pgq/
Show pgq status
crmmbqt=# select * from pgq.get_consumer_info() where queue_name = 'londiste3_queue';
┌─────────────────┬───────────────────┬─────────────────┬─────────────────┬───────────┬───────────────┬───────────┬────────────────┐
│   queue_name    │   consumer_name   │       lag       │    last_seen    │ last_tick │ current_batch │ next_tick │ pending_events │
├─────────────────┼───────────────────┼─────────────────┼─────────────────┼───────────┼───────────────┼───────────┼────────────────┤
│ londiste3_queue │ .global_watermark │ 02:12:20.5365   │ 00:01:16.560372 │     14376 │          NULL │      NULL │          13333 │
│ londiste3_queue │ londiste3_slave   │ 00:04:48.404077 │ 00:00:00.014105 │     14630 │       5070555 │     14631 │            252 │
│ londiste3_queue │ .slave.watermark  │ 02:09:20.494378 │ 00:00:07.537384 │     14381 │          NULL │      NULL │          10910 │
└─────────────────┴───────────────────┴─────────────────┴─────────────────┴───────────┴───────────────┴───────────┴────────────────┘
(3 rows)