Skip to main content
The seg extension provides support for representing line segments or floating-point intervals in PostgreSQL. This type represents both ranges of values and also measurements with uncertainty, randomness or tolerances. Your Nile database arrives with the seg extension already enabled.

Overview

The seg extension adds a new data type seg that can represent:
  • Line segments on a number line
  • Floating-point intervals
  • Exact or inexact bounds
  • Infinite bounds using < x or > x notation

Data Type Format

The seg data type accepts several input formats:

Examples

Creating Segments

Comparison Operations

Working with Measurement Ranges

Use Cases

The seg extension can be used with any type of data that can be represented as a floating-point interval. But it is most useful for recording laboratory measurements with uncertainty or tolerances.

Performance Optimization

For better query performance with seg data:
  1. Create GiST indexes on seg columns:
  1. Common operators that can use the GiST index:
  • << (strictly left of)
  • >> (strictly right of)
  • &< (does not extend right of)
  • &> (does not extend left of)
  • && (overlaps)
  • @> (contains)
  • <@ (contained in)

Additional Resources