From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Felipe Santos <felipepts(at)gmail(dot)com> |
Cc: | Igor Neyman <ineyman(at)perceptron(dot)com>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Melvin Davidson <melvin6925(at)gmail(dot)com>, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, Thomas Kellerer <spam_eater(at)gmx(dot)net> |
Subject: | Re: BRIN indexes |
Date: | 2016-01-30 16:24:02 |
Message-ID: | 20160130162402.GA20949@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Felipe Santos wrote:
> brin_db=# EXPLAIN ANALYSE SELECT count(*) FROM orders WHERE order_date
> BETWEEN '2012-01-04 09:00:00' and '2014-01-04 14:30:00';
>
> QUERY PLAN
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------
> -----------------
> Aggregate (cost=2408269.34..2408269.35 rows=1 width=0) (actual
> time=14164.923..14164.923 rows=1 loops=1)
> -> Bitmap Heap Scan on orders (cost=326808.28..2328609.76
> rows=31863832 width=0) (actual time=42.742..11430.562 rows=31589101 loops=1)
> Recheck Cond: ((order_date >= '2012-01-04 09:00:00-02'::timestamp
> with time zone) AND (order_date <= '2014-01-04 14:30:00-02'::timestamp with
> time zone))
> Rows Removed by Index Recheck: 21907
> Heap Blocks: lossy=201344
> -> Bitmap Index Scan on idx_order_date_brin
> (cost=0.00..318842.32 rows=31863832 width=0) (actual time=36.151..36.151
> rows=2013440 loops=1)
> Index Cond: ((order_date >= '2012-01-04
> 09:00:00-02'::timestamp with time zone) AND (order_date <= '2014-01-04
> 14:30:00-02'::timestamp
> with time zone))
> Planning time: 0.297 ms
> Execution time: 14164.985 ms
> (9 rows)
The number of blocks read from the heap is a key number to watch for,
because when you get concurrency that's what going to matter the most.
Here you have 201k buffer reads, versus, uh, I don't know how many pages
read (because you didn't use the VERBOSE explain option). I think it's
worth comparing how many buffer accesses your query had to read.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | David Unsworth | 2016-01-30 16:24:20 | Cannot start the PostgreSQL service |
Previous Message | Craig Ringer | 2016-01-30 14:36:25 | Re: BDR replication |