6 पॉइंट द्वारा GN⁺ 2024-05-21 | 1 टिप्पणियां | WhatsApp पर शेयर करें

Time-series डेटा क्या है?

  • Time-series डेटा उन डेटा पॉइंट्स का संग्रह है जिनमें हर पॉइंट के साथ timestamp जुड़ा होता है
  • उदाहरण: stock price, डिवाइस और sensor से मिलने वाला temperature और availability डेटा, वेबसाइट का traffic डेटा
  • Time-series workloads में आमतौर पर time filtering queries और डेटा सारांश के लिए aggregate queries शामिल होती हैं

PostgreSQL के साथ time-series workloads

  • PostgreSQL अपनी extensibility और ecosystem tools की वजह से हर तरह के डेटा workloads को संभाल सकता है
  • Tembo का लक्ष्य है कि यूज़र PostgreSQL ecosystem को आसानी से इस्तेमाल कर सकें
  • ग्राहकों की सबसे बड़ी मांग एक ऐसा stack था जो time-series डेटा को store और process कर सके

pg_timeseries के components

  • Time-series डेटा को efficiently store और query करने के लिए ज़रूरी बातें:
    • Time-series डेटा को आसानी से manage करना
    • high throughput संभालना
    • range queries का तेज़ जवाब देना
    • बड़े पैमाने के डेटा को efficiently store करना
    • complex analytical functions चलाना
  • PostgreSQL की built-in capabilities:
    • native partitioning, विभिन्न indexes, materialized views, window/analytical functions
  • अतिरिक्त extensions:
    • pg_partman: partition management
    • pg_cron: job scheduling
    • columnar: compression
    • pg_ivm: incremental materialized views
    • pg_tier: पुराने partitions का long-term offload

pg_timeseries: PostgreSQL में time-series डेटा को manage करने का सबसे आसान तरीका

  • pg_timeseries कई extensions की capabilities को जोड़कर एक unified interface देता है
  • शुरू करने के लिए time-related column पर partition की गई table चाहिए
    CREATE TABLE measurements (  
      metric_name text,  
      metric_value numeric,  
      metric_time timestamptz NOT NULL  
    ) PARTITION BY RANGE (metric_time);  
    
    SELECT enable_ts_table('measurements');  
    
  • महत्वपूर्ण जानकारी देने के लिए कई views शामिल हैं:
    SELECT table_id, table_size_bytes FROM ts_table_info;  
    SELECT * FROM ts_part_info;  
    
  • Partitions के लिए compression और deletion policies सेट की जा सकती हैं:
    SELECT set_ts_compression_policy('measurements', '90 days');  
    SELECT set_ts_retention_policy('measurements', '365 days');  
    
  • अतिरिक्त functions भी दिए गए हैं:
    SELECT  
      locf(avg(metric_value)) OVER (ORDER BY metric_time) avg_val,  
      last(metric_name, metric_value) highest,  
      metric_time  
    FROM date_bin_table(NULL::measurements, '1 hour', '[2024-05-09,2024-06-07]');  
    

हम अभी बस शुरुआत में हैं

  • PostgreSQL के लिए time-series extension बनाने में कई components की ज़रूरत होती है
  • इसे community के साथ open में build करने की योजना है
  • मौजूदा roadmap:
    • पुराने partitions को S3 जैसी cold storage में offload करना
    • efficient analytics के लिए approximate functions
    • incremental materialized views
    • पुराने partitions का rollup और rolloff
    • अतिरिक्त analytical helper functions
  • पूरा roadmap GitHub README में है, और features की priority यूज़र demand के आधार पर तय होगी

GN⁺ की राय

  • Time-series डेटा का महत्व: IoT, finance, web analytics जैसे कई क्षेत्रों में time-series डेटा का महत्व बढ़ रहा है। pg_timeseries ऐसे डेटा को efficiently manage करने के लिए tools देता है।
  • PostgreSQL की extensibility: PostgreSQL की extension capabilities का उपयोग करके अलग-अलग डेटा workloads को संभाला जा सकता है। pg_timeseries इन capabilities को integrate करके यूज़र की सुविधा बढ़ाता है।
  • Community के साथ सहयोग: यह open source के रूप में विकसित हो रहा है, इसलिए community feedback को शामिल किया जा सकता है। इससे feature improvements और bug fixes में बड़ी मदद मिलती है।
  • प्रतिस्पर्धी प्रोडक्ट्स: TimescaleDB जैसे दूसरे time-series databases की तुलना में इसका फायदा यह है कि इसे license restrictions के बिना इस्तेमाल किया जा सकता है। हालांकि performance और features के लिहाज़ से तुलना अभी भी ज़रूरी है।
  • Adoption पर विचार: pg_timeseries को अपनाते समय मौजूदा database के साथ compatibility, performance, maintenance cost आदि पर ध्यान देना चाहिए। साथ ही, time-series डेटा की प्रकृति के कारण डेटा की मात्रा तेज़ी से बढ़ सकती है, इसलिए उचित storage management भी ज़रूरी है।

1 टिप्पणियां

 
GN⁺ 2024-05-21
Hacker News टिप्पणियाँ

Hacker News टिप्पणियों का सारांश

  • Incremental Materialized Views

    • Incremental materialized views मुख्य फीचर है, जो डेटा आने पर हर बार performance घटे बिना इसे up-to-date रख सकता है.
    • जिज्ञासा है कि क्या pg_ivm जैसी implementation इस्तेमाल होगी, या इसे खुद implement किया जाएगा.
    • उम्मीद है कि किसी दिन PostgreSQL core में IVM शामिल होगा.
  • TimescaleDB से तुलना

    • TimescaleDB की license restrictions के कारण compression, incremental materialized views, infinite storage जैसी features का उपयोग नहीं किया जा सकता.
    • यह माना गया कि इन features के बिना ग्राहकों की time-series data requirements पूरी नहीं हो सकतीं, इसलिए PostgreSQL-licensed extension खुद बनाया गया.
    • TimescaleDB के free version का उपयोग करके 500 million observations वाले database को shard करने का अनुभव रहा है. यह बिना किसी बड़ी समस्या के चला.
    • अच्छा होता अगर benchmarks और comparisons भी होते. इस पर नज़र बनी रहेगी.
  • Append-Only tables

    • अब समय आ गया है कि PostgreSQL और दूसरे databases में native append-only tables जोड़े जाएँ.
    • यह खुद time-series database नहीं है, लेकिन standardization से जुड़ी logic/approach में मदद करेगा.
  • Time-series databases का विकास

    • Time-series databases इस तरह विकसित हो रहे हैं:
      • columnar storage और Parquet व Arrow जैसे open formats की ओर convergence: InfluxDB 3.0, QuestDB
      • PostgreSQL के ऊपर time-series features जोड़ना: Timescale, pg_timeseries
      • Prometheus ecosystem के इर्द-गिर्द observability platforms: Grafana, Victoria Metrics, Chronosphere
  • Columnar storage की आवश्यकता

    • ज़्यादातर time-series queries aggregate queries होती हैं.
    • इसके लिए best-in-class columnar storage का उपयोग या निर्माण करना बेहतर है.
    • सवाल है कि ClickHouse जैसी चीज़ PostgreSQL में क्यों नहीं है.
  • उपयोगी links

    • trunk और pgt.dev के बारे में जानकर अच्छा लगा.
  • Load balancer log entries

    • जिज्ञासा है कि load balancer log entries (status, response body, headers आदि) को handle करते समय यह extension उपयोगी होगा या नहीं.
    • लगता है कि columnar database storage, सामान्य row-based databases की तुलना में अधिक efficient होगा.
    • Load balancer log entries को analytics events जैसा माना जा सकता है.
  • Open source innovation

    • PostgreSQL हमेशा से open source रहा है, और इसने बहुत permissive open source libraries का उपयोग किया है.
    • replication से लेकर time-series support तक, कई proprietary और source-available extensions रहे हैं.
    • अब इन proprietary extensions को उचित open source विकल्पों से चुनौती मिल रही है.
  • PostgreSQL license

    • PostgreSQL license का उपयोग करना एक अच्छा फैसला है.
  • Site design और app UI

    • Site design अच्छा है और पढ़ने में आसान है.
    • Demo images में app UI भी शानदार दिखता है. इसे आज़माने की इच्छा है.