postgresql – Why does my Query use a Bitmap Heap Scan


my simple query is not really fast and I don’t know why my query is using Bitmap Heap Scan.

explain analyze verbose SELECT connections, epoch_time FROM connections WHERE host_name = ‘xyz.z’ ORDER BY epoch_time;

Output:

                                                           QUERY PLAN

Sort (cost=3257.93..3316.47 rows=23415 width=13) (actual time=8.607..9.624 rows=23259 loops=1)
Output: connections, epoch_time
Sort Key: connections.epoch_time
Sort Method: quicksort Memory: 1859kB
-> Bitmap Heap Scan on public.connections (cost=545.88..1558.57 rows=23415 width=13) (actual time=1.341..5.840 rows=23259 loops=1)
Output: connections, epoch_time
Recheck Cond: ((connections.host_name)::text = ‘xyz.z’::text)
Heap Blocks: exact=651
-> Bitmap Index Scan on idx_host_name (cost=0.00..540.03 rows=23415 width=0) (actual time=1.266..1.266 rows=23259 loops=1)
Index Cond: ((connections.host_name)::text = ‘xyz.z’::text)
Planning Time: 0.171 ms
Execution Time: 10.405 ms
(12 rows)

The table has 97806 rows and I have created an index on the field epoch_time. The table has 4 columns (id, host_name, connections, epoch_time)

Thanks for your help!

Best regards