Re: using possibly null timestamptz columns
| От | Tom Lane |
|---|---|
| Тема | Re: using possibly null timestamptz columns |
| Дата | |
| Msg-id | 5086.1475154348@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | using possibly null timestamptz columns (James Cloos <cloos@jhcloos.com>) |
| Ответы |
Re: using possibly null timestamptz columns
|
| Список | pgsql-sql |
James Cloos <cloos@jhcloos.com> writes:
> Given a table with a pair of timestamptz columns (lets call them s and e)
> which are typically null, is there a better way to write this where clause
> snippet:
> where ( s is null or s <= now() ) and ( e is null or e >= now() )
You could try constructing a GIST or SPGIST index on the ranges
tstzrange(s, e), where you'd have to do something to convert null
endpoints to infinities, and then probing with WHERE rangeexpr @> now().
I'm not really sure how well this would perform, but certainly you're
dead in the water as far as doing anything useful with regular btree
indexes.
regards, tom lane
В списке pgsql-sql по дате отправления: