Re: Minmax indexes

Поиск
Список
Период
Сортировка
От Erik Rijkers
Тема Re: Minmax indexes
Дата
Msg-id 66917e7897c3a814996b6d6a5cda6d22.squirrel@webmail.xs4all.nl
обсуждение исходный текст
Ответ на Re: Minmax indexes  ("Erik Rijkers" <er@xs4all.nl>)
Ответы Re: Minmax indexes  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
On Thu, September 26, 2013 00:34, Erik Rijkers wrote:
> On Wed, September 25, 2013 22:34, Alvaro Herrera wrote:
>
>> [minmax-5.patch]
>
> I have the impression it's not quite working correctly.
>
> The attached program returns different results for different values of enable_bitmapscan (consistently).
>
> ( Btw, I had to make the max_locks_per_transaction higher for even not-so-large tables -- is that expected?  For a
100Mrow
 
> table, max_locks_per_transaction=1024 was not enough; I set it to 2048.  Might be worth some documentation,
eventually.)
 
>
> From eyeballing the results it looks like the minmax result (i.e. the result set with enable_bitmapscan = 1) yields
only
> the last part because the only 'last' rows seem to be present (see the values in column i in table tmm in the
attached
> program).

Looking back at that, I realize I should have added a bit more detail on that test.sh program and its output (attached
on
previous mail).

test.sh creates a table tmm and a minmax index on that table:

testdb=# \d tmm     Table "public.tmm"Column |  Type   | Modifiers
--------+---------+-----------i      | integer |r      | integer |
Indexes:   "tmm_minmax_idx" minmax (r)


The following shows the problem:  the same search with minax index on versus off gives different result sets:

testdb=# set enable_bitmapscan=0; select count(*) from tmm where r between symmetric 19494484 and 145288238;
SET
Time: 0.473 mscount
------- 1261
(1 row)

Time: 7.764 ms
testdb=# set enable_bitmapscan=1; select count(*) from tmm where r between symmetric 19494484 and 145288238;
SET
Time: 0.471 mscount
-------    3
(1 row)

Time: 1.014 ms



testdb=# set enable_bitmapscan =1; select * from tmm where r between symmetric 19494484 and 145288238;
SET
Time: 0.615 ms i   |     r
------+-----------9945 |  454056039951 | 1025524859966 |  63763962
(3 rows)

Time: 0.984 ms

testdb=# set enable_bitmapscan=0; select * from ( select * from tmm where r between symmetric 19494484 and 145288238
order
by i desc limit 10) f order by i ;
SET
Time: 0.470 ms i   |     r
------+-----------9852 | 1149969069858 |  699071699875 |  433415839894 | 1278626579895 |  447400339911 |  517975539916
| 585387749945 |  454056039951 | 1025524859966 |  63763962
 
(10 rows)

Time: 8.704 ms
testdb=#

If enable_bitmapscan=1 (i.e. using the minmax index), then only some values are retrieved (in this case 3 rows).   It
turns
out those are always the last N rows of the full resultset (i.e. with enable_bitmapscan=0).


Erikjan Rijkers





В списке pgsql-hackers по дате отправления:

Предыдущее
От: Noah Misch
Дата:
Сообщение: Re: pgbench - exclude pthread_create() from connection start timing
Следующее
От: Antonin Houska
Дата:
Сообщение: Re: [PATCH] bitmap indexes