我有一個大型空間資料集(1.5 億),其中包含 10 個不同年份的時間點。我想在一個簡單而有效的查詢中獲取每年 1 月 15 日到 6 月 15 日之間的物件。
postgresql中是否有任何日月日期時間格式?有任何想法嗎?
謝謝!
uj5u.com熱心網友回復:
一個簡單的方法是:
where (extract(month from the_date_column), extract(day from the_date_column))
between (1,15) and (6,15)
這可以利用索引:
create index on the_table ( extract(month from the_date_column), extract(day from the_date_column) ) ;
uj5u.com熱心網友回復:
替代
where to_char(the_date_column, 'mmdd') between '0115' and '0615'
和相應的索引
create index on the_table (to_char(the_date_column, 'mmdd')) ;
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/516235.html
下一篇:重置時如何保留我的日期文本框值
