Install and load
Run these commands in a Haybarn SQL session. The extension is available from the community repository.
INSTALL tsid FROM community;
LOAD tsid FROM community;
Try it in a temporary SQL session with tsid already loaded. Queries run in this tab; examples using files or services need their own setup.
Using upstream DuckDB? Follow the maintainerβs installation instructions.
Usage example
Generate a new time-sortable ID (accepts an optional seed string)
-- Generate a new time-sortable ID (accepts an optional seed string)
D SELECT tsid();
ββββββββββββββββββββββββββββββββββββ
β tsid() β
β varchar β
ββββββββββββββββββββββββββββββββββββ€
β 675716e86985495e9cf575f0b9c4a8db β
ββββββββββββββββββββββββββββββββββββ
-- Extract timestamp from a TSID
D SELECT tsid_to_timestamp('675716e86985495e9cf575f0b9c4a8db');
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β tsid_to_timestamp('675716e86985495e9cf575f0b9c4a8db') β
β timestamp β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 2024-12-09 16:12:24.44259 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-- Verify TSID ordering
D SELECT
a.id as id1,
b.id as id2,
tsid_to_timestamp(a.id) as ts1,
tsid_to_timestamp(b.id) as ts2
FROM
(SELECT tsid('a') as id FROM range(1)) a,
(SELECT tsid('b') as id FROM range(1)) b;
ββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ
β id1 β id2 β ts1 β ts2 β
β varchar β varchar β timestamp β timestamp β
ββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββ€
β 6757176b9d4640b299be06ff79ed1373 β 6757176b9d704dcf8a1dce8bb6da51bf β 2024-12-09 16:14:35.659653 β 2024-12-09 16:14:35.660354 β
ββββββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββ
Provided by quackscience. Not yet verified on Haybarn 2.0.0.
Sample data & setupDocumentation and resources
Project and build details
- Repository
- quackscience/duckdb-extension-tsid
- License
- MIT
- Maintainers
- lmangani, rustyconover
- Written in
- C++
- Build source
dfb495e89e01- Build definition
- Community descriptor