I have more than 1 million rows in the table and my SELECT
query is slow when I search between date range .
So, I have the following table
CREATE TABLE public.main_transaction
(
id integer NOT NULL DEFAULT nextval('main_transaction_id_seq'::regclass),
description character varying(255) NOT NULL,
transaction_type character varying(18) NOT NULL,
pub_date timestamp with time zone NOT NULL,
...
)
Above table has 34 columns including 3 FOREIGN KEY
s and
I want to speed up the following query.
SELECT * FROM main_transaction
WHERE
pub_date >= '2018-01-01'
AND pub_date <'2018-01-08'
Now, it is working in 12 secs. :(
By the way, I have tried this solution. However, I didn't notice much change.
execution plan:
Seq Scan on main_transaction t (cost=0.00..74437.33 rows=28974 width=1455)
Filter: ((pub_date >= '2018-01-01 00:00:00+05'::timestamp with time zone) AND (pub_date < '2018-01-08 00:00:00+05'::timestamp with time zone))