What is the type start_time? I guess it is timestamp, not date.
The expression CAST(start_time AS DATE)does not allow the optimizer to use the index on start_time. Usually, any expression above a column does not allow the optimizer to use the index.
.
SELECT COUNT(uniq_id)
FROM call_fact
WHERE
source_key=2
AND start_time >= '2018-01-23'
AND start_time < '2018-01-24'
;
Postgres , 2018-01-23 date timestamp. ( start_time date. , . SQL Server " ", Postgres.
, / , timestamp, .
SELECT COUNT(uniq_id)
FROM call_fact
WHERE
source_key=2
AND start_time >= '2018-01-23 00:00:00'
AND start_time < '2018-01-24 00:00:00'
;
, start_time.