Slow query on “UNION ALL” view

后端 未结 8 1894
伪装坚强ぢ
伪装坚强ぢ 2021-02-13 06:20

I have a DB view which basically consists of two SELECT queries with UNION ALL, like this:

CREATE VIEW v AS
SELECT time, etc. FROM t1 /         


        
8条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-13 07:00

    I do not know Postgres, but some RMDBs handle comparison operators worse than BETWEEN in case of indexes. I would make an attempt using BETWEEN.

    SELECT ... FROM v WHERE time BETWEEN ... AND ...
    

提交回复
热议问题