Re: Proposition for better performance

2018-03-27 Thread armand pirvu
> On Mar 27, 2018, at 4:25 PM, Paul Jungwirth > wrote: > > On 03/27/2018 11:42 AM, hmidi slim wrote: >> This is the message that I got: >> Successfully run. Total query runtime: 2 min. >> 1500 rows affected. > > Sorry, I don't think this is enough information to suggest anything. > > --

Re: Proposition for better performance

2018-03-27 Thread Paul Jungwirth
On 03/27/2018 11:42 AM, hmidi slim wrote: This is the message that I got: Successfully run. Total query runtime: 2 min. 1500 rows affected. Sorry, I don't think this is enough information to suggest anything. -- Paul ~{:-) p...@illuminatedcomputing.com

Re: Proposition for better performance

2018-03-27 Thread hmidi slim
This is the message that I got: Successfully run. Total query runtime: 2 min. 1500 rows affected.

Re: Proposition for better performance

2018-03-27 Thread Paul Jungwirth
On 03/27/2018 11:14 AM, hmidi slim wrote: Query plan:* Bitmap Heap Scan on product_availabilities  (cost=33728.79..236086.04 rows=878500 width=26) (actual time=2775.058..5792.842 rows=1500 loops=1)   Recheck Cond: (during @> '[2018-02-01,2018-04-01)'::daterange)   Heap Blocks: exact=31040

Re: Proposition for better performance

2018-03-27 Thread Paul Jungwirth
(Including the list) On 03/27/2018 10:49 AM, hmidi slim wrote: Sorry I didn't copy it very well: create index idx on availability using gist(during); and during = daterange(start_date,end_date) And the query plan used was seq scan not index scan. It sounds like there must be some importa

Re: Proposition for better performance

2018-03-27 Thread hmidi slim
I update the example: *create table product_availabilities(product_id integer, start_date date, end_date date); insert into product_availabilities(product_id, start_date, end_date) select a, '2018-01-01', '2018-05-03' from generate_series(1,1500) as aalter ta

Re: Proposition for better performance

2018-03-27 Thread Paul Jungwirth
On 03/27/2018 10:04 AM, hmidi slim wrote: 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 i

Re: Proposition for better performance

2018-03-27 Thread hmidi slim
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(durin

Re: Proposition for better performance

2018-03-27 Thread Paul Jungwirth
On 03/27/2018 07:42 AM, hmidi slim wrote: Hi, I'm trying to create an availability table for existing products. I'm fetching the suitable schema to design in order to get good performance when I fetch products in a table contains millions of rows. I think to make a schema like this: *create ta

Proposition for better performance

2018-03-27 Thread hmidi slim
Hi, I'm trying to create an availability table for existing products. I'm fetching the suitable schema to design in order to get good performance when I fetch products in a table contains millions of rows. I think to make a schema like this: *create table availability (product_id integer, product_n