the query that I used to fetch products was:
select * from availability
where ('27-03-2018' between start_date and end_date)
and ('31-03-2018' between start_date and end_date);

I added another column named during of type daterange and I created a gist
index :
create index idx on availability(during);

select * from availability
where during @> daterange(''27-03-2018', '31-03-2018');

With a table of 15M rows I got an execution time of 1 minute.Thtat's why I
asked if it is a good solution to divide the availability of a product by
intervals.
If I assume that a product has in every month 5 availability intervals, in
12 months we will have 60 intervals.For 1M products that's will be 60M
rows. This will affect the performance.

Reply via email to