Skip to content

feat(sql): add table_min_ and table_max_timestamp columns to tables() view#6630

Merged
bluestreak01 merged 4 commits intomasterfrom
vi_min_max
Jan 13, 2026
Merged

feat(sql): add table_min_ and table_max_timestamp columns to tables() view#6630
bluestreak01 merged 4 commits intomasterfrom
vi_min_max

Conversation

@bluestreak01
Copy link
Copy Markdown
Member

@bluestreak01 bluestreak01 commented Jan 13, 2026

Documentation PR: questdb/documentation#323

Summary

This PR adds table_min_timestamp and table_max_timestamp columns to the tables() function, which expose the actual data timestamp range in each table. These values are updated when WAL transactions are merged into tables and during startup hydration.

Changes

New columns in tables():

  • table_min_timestamp - Minimum timestamp of data in the table
  • table_max_timestamp - Maximum timestamp of data in the table

Renamed columns for clarity:

  • table_max_timestamptable_last_write_timestamp (timestamp of last TableWriter commit, not data timestamp)
  • dedup_row_count_since_startwal_dedup_row_count_since_start (consistent wal_ prefix)

Column reordering:
The new timestamp columns are placed just before table_last_write_timestamp:

table_row_count → table_min_timestamp → table_max_timestamp → table_last_write_timestamp → table_txn

Implementation Details

  • TableWriter.java: Added public getMinTimestamp() method
  • RecentWriteTracker.java:
    • Added tableMinTimestamp/tableMaxTimestamp fields to WriteStats
    • Updated recordMergeStats() to capture timestamps during WAL apply
    • Updated recordWriteIfAbsent() to capture timestamps during startup hydration
    • Renamed timestamp parameter to writeTimestamp for clarity
  • ApplyWal2TableJob.java: Passes min/max timestamps to recordMergeStats()
  • CairoEngine.java: Passes min/max timestamps during tracker hydration
  • TablesFunctionFactory.java: Added new columns and updated column indices

Test plan

  • Existing ShowTablesTest and TablesFunctionFactoryTest updated and passing
  • RecentWriteTrackerTest updated to verify timestamp capture
  • Manual verification: SELECT table_name, table_min_timestamp, table_max_timestamp FROM tables()

🤖 Generated with Claude Code

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 13, 2026

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@glasstiger
Copy link
Copy Markdown
Contributor

[PR Coverage check]

😍 pass : 55 / 58 (94.83%)

file detail

path covered line new line coverage
🔵 io/questdb/griffin/engine/functions/catalogue/TablesFunctionFactory.java 32 35 91.43%
🔵 io/questdb/cairo/TableWriter.java 1 1 100.00%
🔵 io/questdb/cairo/pool/RecentWriteTracker.java 15 15 100.00%
🔵 io/questdb/cairo/CairoEngine.java 3 3 100.00%
🔵 io/questdb/cairo/wal/ApplyWal2TableJob.java 4 4 100.00%

@bluestreak01 bluestreak01 merged commit 553549b into master Jan 13, 2026
43 checks passed
@bluestreak01 bluestreak01 deleted the vi_min_max branch January 13, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants