23.3. Querying Hot and Cold Data Simultaneously #

This guide describes how to query hot and cold data with a single command. For the steps below, it is assumed that the hot data is stored in the axe_heap_table heap table, and the cold data is stored in the axe_archive_table and axe_archive_s3_table analytical tables.

  1. Create a view that merges the data from the axe_heap_table heap table and the axe_archive_table and axe_archive_s3_table analytical tables.

    For example:

      CREATE VIEW public.axe_table AS
      SELECT * FROM public.axe_heap_table
      UNION ALL
      SELECT id, "name", price, created_at FROM public.axe_archive_table
      UNION ALL
      SELECT id, "name", price, created_at FROM public.axe_archive_s3_table;
    
  2. Execute analytical queries on the view.

    For example:

      SELECT
          date_trunc('month', created_at) AS month,
          sum(price) AS revenue
      FROM public.axe_table
      WHERE created_at >= TIMESTAMP '2023-01-01'
      GROUP BY 1
      ORDER BY 1;
    

Note

If the analytical tables that a query accesses are partitioned (e.g., by the year and month columns) and the query filters data by the partition columns, the analytics engine skips the Parquet files that cannot contain the required data. For more information about Hive partitioning, refer to Section 15.2.

FAQ