speedup tidbitmap patch: cache page

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: speedup tidbitmap patch: cache page
Date: 2014-10-22 11:52:37
Message-ID: 54479A85.8060309@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

In specific workload postgres could spend a lot of time in tbm_add_tuples, up
to 50% of query time. hash_search call is expensive and called twice for each
ItemPointer to insert. Suggested patch tries to cache last PagetableEntry
pointer in hope that next ItemPointer will be on the same relation page.

Patch is rather trivial and I don't believe that it could cause performance
degradation. But it could increase performance on some workload.

An example:
# create extension btree_gin;
# select (v / 10)::int4 as i into t from generate_series(1, 5000000) as v;
# create index idx on t using gin (i);
# set enable_seqscan = off;

# explain analyze select * from t where i >= 0;
without patch: Execution time: 2427.692 ms
with patch: Execution time: 2058.718 ms

# explain analyze select * from t where i >= 100 and i<= 100;
without patch: Execution time: 524.441 ms
with patch: Execution time: 195.381 ms
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/

Attachment Content-Type Size
tbm_cachepage-1.patch.gz application/x-gzip 637 bytes


Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2014-10-22 11:53:53 Re: BUG: *FF WALs under 9.2 (WAS: .ready files appearing on slaves)
Previous Message Marti Raudsepp 2014-10-22 11:44:16 Re: btree_gin and ranges